increasing values midway of an array for theta (using atan2();)

1 回表示 (過去 30 日間)
Michal Sleszynski
Michal Sleszynski 2020 年 2 月 6 日
編集済み: Michal Sleszynski 2020 年 2 月 6 日
Im wondering if this is an atan2 problem #if so how can i fix it# . I have values of theta that are decreasing and then they start to increase and so the polarplot im producing shows a spiral that turns around at some point. You can view the arrays in the txt files attached . All variables/arrays are of the size 1x101.
Thank you in advance.
theta = atan2(r,t);
theta = theta*360;
rho = sqrt((t.^2)+(r.^2));
figure
polarplot(theta,rho,'b')

回答 (1 件)

Steven Lord
Steven Lord 2020 年 2 月 6 日
Remember is that atan2 returns values in the closed interval [-pi, pi] so if you go from a y that is just barely positive to one that is just barely negative and x is negative, you'll experience that "sudden drop". The unwrap function may be useful to you in that scenario.
By the way, if you wanted to have theta in degrees that's not the right conversion. You should use atan2d instead. But polarplot expects its theta input to be in radians, so maybe just eliminate the multiplication by 360.
  2 件のコメント
Michal Sleszynski
Michal Sleszynski 2020 年 2 月 6 日
ill try that now. I used 360 though because i want a spiral and the conversion i make here theta = atan2(r,t); doesnt give me that spiral.
Michal Sleszynski
Michal Sleszynski 2020 年 2 月 6 日
編集済み: Michal Sleszynski 2020 年 2 月 6 日
unwrap didnt work on my theta i di change the conversion a bit , the result being equivilent to what i get by using *360
theta = atan2(r,t);
theta = 2*pi*(theta)*180/pi;
theta = unwrap(theta);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSatellite and Orbital Mechanics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by