asin and acos quadrant check function help

29 次查看(过去 30 天)
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 个)

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 CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by