Re-scaling matrix entries to lie within a range
2 ビュー (過去 30 日間)
古いコメントを表示
Hey all,
Basically, I have a matrix containing a wide range of phase angles, but I want to re-scale all these angles to their equivalent values within the range [-pi, pi]. Hence, for example, 1.5*pi will become -0.5*pi.
Would anyone have any tips on how to do this? I'm not looking for a full answer; merely any suggestions that would help me get started would be much appreciated!
Craig
0 件のコメント
採用された回答
Sven
2011 年 11 月 21 日
You can use the "mod" command with modulus 2*pi, then minus pi from the result. For example:
mod(4.5*pi + pi, 2*pi) - pi
ans =
-1.5708
mod(1.5*pi + pi, 2*pi) - pi
ans =
1.5708
(above edited for Walter's amendment)
3 件のコメント
Sven
2011 年 11 月 22 日
Oops. Yep, you're right of course Walter.. what can I say... I was in a rush? Edited accordingly :)
その他の回答 (2 件)
Walter Roberson
2011 年 11 月 22 日
mod(angle + pi, 2*pi) - pi
Note: this will produce the range semi-open interval [-pi, pi) . The original closed interval [-pi, pi] is ambiguous as to what -pi or pi exactly should map to (as they are the same angle)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!