フィルターのクリア

asin and acos quadrant check function help

29 ビュー (過去 30 日間)
Adam Francki
Adam Francki 2019 年 3 月 19 日
回答済み: Alex Mcaulley 2019 年 3 月 19 日
Hi I'm trying to work out how to write a code for a quadrant check to get the right angle. An example of what I'm trying to acheive is below:
The C11, C21, C31 are matrix elements from a direciton cosine matrix
Alpha=78.52
Sigma1=asin(C21./sind(Alpha)); % where C21./sind(Alpha)=0.9695
Sigma2=acos(-C31./sind(Alpha)); %where -C31./sind(Alpha)=-0.2452
Now from the above calculation MATLAB gives
Sigma1=75.8 % Second solution manually calculated by me is 104.2
Sigma2=104.2 % Second solution manually calculated by me is -104.2
how would I automate a check for MATLAB to determine that 104.2 is the correct solution from Sigma1 and Sigma2 and then give Sigma=104.2 as the final solution. I would need this automated im gueesing using for,if,ifelse functions to do this but I'm not sure how.
Any help would be great! Thanks!
  1 件のコメント
KSSV
KSSV 2019 年 3 月 19 日
Check your units of angles...

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

回答 (1 件)

Alex Mcaulley
Alex Mcaulley 2019 年 3 月 19 日
asind(x) %gives values between [-90,90]
acosd(x) %gives values between [0,180]
Then if you want all the values between [0,360] you can use trigonometric identities: sin(x)=sin(pi-x), and then
angle = asind(x);
angle2 = 180-a
And for the cosine cos(x)=cos(-x):
angle = acosd(x);
angle2 = 360-a
And then you can chose the one that you want.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by