How to determine if angles match
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Madeleine
am 20 Feb. 2024
Kommentiert: Madeleine
am 21 Feb. 2024
I am trying to write code to determine when two precession angles match. Matlab keeps skipping to the last else statement regardless of which elseif statement should be taking precedence.
prec1 = rad2deg(acos(C21./sin(deg2rad(nutation))));
prec2 = rad2deg(asin(C31./sin(deg2rad(nutation))));
if abs(prec1 - prec2) < 10^-3
prec = prec1;
elseif abs(prec1 - (180 - prec2))< 10^-3
prec = prec1;
elseif abs((360 - prec1) - prec2) < 10^-3
prec = prec2;
else
prec = 360 - prec1;
end
4 Kommentare
Akzeptierte Antwort
Walter Roberson
am 20 Feb. 2024
You would get that behavior if prec1 or prec2 are non-scalar and it does not happen that all of the values pass the tests.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!