角度の求め方

24 views (last 30 days)
riku
riku on 24 Jan 2018
Answered: Akira Agata on 29 Jan 2018
atan2から求めたθの値から‐π/2したいのですが、そのまま引くと-πからπの範囲を超えてしまいます。 どうすれば-πからπの範囲で計算することができますか?

Accepted Answer

Kei Otsuka
Kei Otsuka on 24 Jan 2018
atan2を求める前に-pi/2位相回転してみてはどうでしょうか。
% 基準となる複素数を定義
z1 = -4 -3i;
% atan2を求める
theta = atan2(imag(z), real(z))
% -pi/2してみる
theta -pi/2
上記を実行すると-4.0689となります(孤の中心に対する角度という観点では2.2143と等価)。 ここで、atan2を求める前に-pi/2だけ位相を回してみます。
% -pi/2位相を回転させる。
z2 = -i;
z3 = (real(z1)*real(z2)-imag(z1)*imag(z2)) + (real(z1)*imag(z2)+real(z2)*imag(z1))*i
% atan2でthetaの値を求める
atan2(imag(z2), real(z2))
この場合は2.2143となり、[-pi, pi]の範囲となります。また、Communications System Toolboxをお持ちであれば以下のようなオブジェクトも使えます。
pfo = comm.PhaseFrequencyOffset('PhaseOffset',-90);
y = pfo(z1);
atan2(imag(y), real(y))
  1 Comment
riku
riku on 25 Jan 2018
ありがとうございます。無事解決しました。

Sign in to comment.

More Answers (1)

Akira Agata
Akira Agata on 29 Jan 2018
少々手間ですが、MATLABの基本関数を使ったこんな方法でも対応可能です。
% atan2 で求めた theta の値から -pi/2
theta = theta - pi/2;
% [-pi, pi] の範囲に調整
theta = theta - 2*pi*fix(theta/pi);

Categories

Find more on 三角法 in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!