필터 지우기
필터 지우기

Want to Get Plot To Have Contunuous Angles, Not Stay between -180 and +180 Degrees

조회 수: 13 (최근 30일)
Hello,
As the title states, I have a repeating plot that shows the angle on the x-axis. Currently, it appears as follows:
Notice how a little after .6, it jumps up: it goes from -179 to +179. I would like it to go from -179 to -181, if that makes sense. So basically just one continuous curve.
I tried implementng a while loop, to say "while the variable is greater than 0, subtract 360 from it", and this works for the first jump, but then I have the same error for the next jumps, just now around -180. That looks like as follows:
I guess this is more of a general coding question, rather than a MATLAB specific question, so if it's not applicable here I can try somewhere else.
Any help is appreciated. I can show snippets of my code as well if that helps.
Thanks,
Jon
Edit: I just tried doing an if/else statement, saying "if the next point in time is greater than the one before it, then subtract 360 from that next point". It's getting a little better, but still not quite there.

채택된 답변

David Goodmanson
David Goodmanson 2021년 4월 15일
편집: David Goodmanson 2021년 4월 15일
Hi Jon,
use
unwrap(your_data,180)
where 180 is just an example and can be anything smaller than the size of the jumps (but not really small like 1 or 2, where the wiggles you see in the waveform might cause unwrap to spring into action). If the second argument to unwrap is not provided, then the function defaults to using pi, which assumes the angles are in radians and uses the equivalent to 180).
  댓글 수: 1
Jon Stapchuck
Jon Stapchuck 2021년 4월 15일
Thank you, that worked when I put 'plot(x,unwrap(y))'
I appreciate your help, much simpler than using loops

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by