angle-betw​een-a-vect​or-and-the​-positive-​x-axis

1 回表示 (過去 30 日間)
Maria Tipikina
Maria Tipikina 2015 年 7 月 9 日
コメント済み: Bjorn Gustavsson 2015 年 7 月 9 日
How can i find an angel between x axis and vector
[fi,ro]=cart2pol(X-X(1),Y-Y(1)-20); [fim1,id]=max(fi); Rom1=ro(id); [xm1,ym1]=pol2cart(fim1,rom1); Xm1=X(1)+[0,xm1]; Ym1=Y(1)+20+[0,ym1];

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2015 年 7 月 9 日
Have a look at the help for atan2.
HTH
  2 件のコメント
Maria Tipikina
Maria Tipikina 2015 年 7 月 9 日
I have read it yet. I can't find angle
Bjorn Gustavsson
Bjorn Gustavsson 2015 年 7 月 9 日
You simply call atan2:
phi = atan2(Ycomponent,Xcomponent);
And there you have your angle between the vector and the x-axis, in radians.
Or more explicitly to calculate the angles for 8 vectors, try this exqample:
plot([1 1 0 -1 -1 -1 0 1]',[0 1 1 1 0 -1 -1 -1]','s-'),axis([-1 1 -1 1]*1.1)
arrow(0*[[0 1 1 1 0 -1 -1 -1]',[1 1 0 -1 -1 -1 0 1]'],[[0 1 1 1 0 -1 -1 -1]',[1 1 0 -1 -1 -1 0 1]'])
atan2([0 1 1 1 0 -1 -1 -1]',[1 1 0 -1 -1 -1 0 1]')*180/pi
(The arrow function you'll have to download from the file exchange.)
HTH

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

カテゴリ

Help Center および File ExchangeAntennas, Microphones, and Sonar Transducers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by