Click to See Complete Forum and Search --> : MatLab - ArcSin, ArcTan


Kella2004
October 10th, 2005, 01:15 PM
So, I am trying to convert Beta Rotation Angles back into Euler angles in MatLab but the problem I am having is that arcsin/tan are used and some of the angles are outside of the limits of -pi/2 - pi/2. I need to either have a if string or sometihing to give me my final angle. This is what i have so far:
CE is a matrix linierized with outputs from my Ode45


if ((CE(:,3)) > -5/2*pi) & ((CE(:,3)) <= 3/2*pi)
theta(:,2) = degrad*-asin(CE(:,3)+2*pi)-360;
end
if ((CE(:,3)) > -3/2*pi) & ((CE(:,3)) < -pi/2)
theta(:,2) = degrad*-asin(CE(:,3)+pi)-180;
end
if ((CE(:,3)) >= -pi/2) & ((CE(:,3)) <= 1/2*pi)
theta(:,2) = degrad*-asin(CE(:,3));
end
if ((CE(:,3)) > pi/2) & ((CE(:,3)) <= 3/2*pi)
theta(:,2) = degrad*-asin(CE(:,3)-pi)+180;
end
if ((CE(:,3)) > 3/2*pi) & ((CE(:,3)) <= 5/2*pi)
theta(:,2) = degrad*-asin(CE(:,3)-2*pi)+360;
end
if ((CE(:,3)) > 5/2*pi) & ((CE(:,3)) <= 7/2*pi)
theta(:,2) = degrad*-asin(CE(:,3)-3*pi)+540;
end
if ((CE(:,3)) > 7/2*pi) & ((CE(:,3)) <= 9/2*pi)
theta(:,2) = degrad*-asin(CE(:,3)-4*pi)+720;
end
if ((CE(:,3)) > 9/2*pi) & ((CE(:,3)) <= 11/2*pi)
theta(:,2) = degrad*-asin(CE(:,3)-5*pi)+900;
end


I think my problem is that it is not just selecting the individual element in the array. Is there a way to make it select individual instances in my CE and theta array?

LMK

Sam T.

Kella2004
October 28th, 2005, 12:42 PM
Well, Thanks to no one, I used a while loop to fix this. worthless fourm.