필터 지우기
필터 지우기

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개)

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