Hi , i have the euler angles ?, ?, ? which i want to input in a function which returns a rotation matrix R in matlab
MATLAB: Input euler angles which outputs rotation matrix R
angleseulerMATLABmatrixrotation
Related Solutions
I needed to parameterise your V equation for it to work with the Optimization Toolbox routines:
% % % p(1) = a, p(2) = b;
V = @(p) -(26*(2000*cos((pi*p(1))/180) + (sin((pi*(p(1) + 45))/180)*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104)))/(3*cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)) - (26*((2^(1/2)*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/(2*((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104)) + (cos((pi*(p(1) + p(2)))/180)*(2000*cos((pi*p(1))/180) + (sin((pi*(p(1) + 45))/180)*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104)))/sin((pi*p(2))/180)))/(3*cos((pi*p(1))/180)^2) - (539047342075749*((2600000*cos((pi*(p(1) + p(2)))/180)*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180)))/(cos((pi*p(1))/180)^2*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180))) + (2600000*cos((pi*p(1))/180)*sin((pi*(p(1) + 45))/180))/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)*(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(1))/180) - sin((pi*(p(1) + p(2)))/180)*cos((pi*p(1))/180)))))/(43980465111040*((1300*(2^(1/2)/2 + (cos((pi*(p(1) + p(2)))/180)*sin((pi*(p(1) + 45))/180))/sin((pi*p(2))/180))^2)/cos((pi*p(1))/180)^3 + (1300*sin((pi*(p(1) + 45))/180)^2)/(cos((pi*(p(1) + p(2)))/180)*sin((pi*p(2))/180)^2) + 8085710131136235/4398046511104));
Since you want to optimise it and the Optimization Toolbox functions minimise it, negating it produced a maximum. (That explains the minus sign.)
The code for the optimisation is:
A = [1 1]; % Constraints
b = 90; % Constraints[angs, fval] = fmincon(V, [1 1]', A, b)asum = angs(1) + angs(2) % Check
The A and b arguments are the equivalent of: (a + b) <= 90. The asum statement simply checks to see that the constraint was met.
The optimisation results are:
angs = -93.3393e+000 180.0000e+000fval = -694.1977e+009asum = 86.6607e+000
I negated V to get the maximum, so in reality fval = 694.1977e+009.
Since the solver uses the Jacobian to find the minimum of the function and reported:
Local minimum possible. Constraints satisfied.fmincon stopped because the size of the current step is less thanthe default value of the step size tolerance and constraints are satisfied to within the default value of the constraint tolerance.
the constraints on the derivatives were satisfied automatically.
Fnum = matlabFunction(F, p, t);
This would create a MATLAB function that had p as its first argument and t as its second argument and which returned an array of numeric values.
Best Answer