asin and acos quadrant check function help

50 views (last 30 days)
Adam Francki
Adam Francki on 19 Mar 2019
Answered: Alex Mcaulley on 19 Mar 2019
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!

Answers (1)

Alex Mcaulley
Alex Mcaulley on 19 Mar 2019
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.

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!