# I need to change a graphic without using unwrap

1 view (last 30 days)
Patricio Morales on 29 Jun 2022
Commented: Jonas on 30 Jun 2022
Please I need a Matlab expert!!
I need this totally discontinuous graph to be transformed into a continuous graph like the one in the following figure, but without using the unwrap function that is built into Matlab. I need if you can guide me and show a code which will help me to achieve the continuity of the graph. It is very important not to use the unwrap function to achieve the goal. Thank you in advance
This is the graph or discontinuous function
I need to get to this graph or function without using the unwrap function

Jonas on 29 Jun 2022
you can unwrap manually. if you have data x and y
myWrapThr=-150;
dy=diff(y);
dy(dy<myWrapThr)=dy(dy<myWrapThr)+180;
newY=cumsum([y(1) dy]);
##### 2 CommentsShowHide 1 older comment
Jonas on 30 Jun 2022
your aim is to remove the jump from approx. +90 to -90. This would equal of exactly -180. depending on the last point before the jump and the first after, the values could also be +86 and -88, then the difference would be only -174. the vatch this natural unprecision, i use a threshold of -150. You could also use -175 as threshold or -170. So my choosing was very generous ;)
this jump values are the corrected by 180 to remove the jump and then the vector is reformed using cumsum on the differental dy
note two things: at the moment the given code only removes jumps near -180 and not +180. But the code can be easily adjusted or expanded for such behavior.
the other point is the unwrapping itself: normally unwrapping is used for visual phase jumps of signals, but those are normally between +-180, or 360 in absolute terms. phases of +- 180 are the equal, but +-90 are not

R2022a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!