No matter the NOA matrix I enter, the result I receive is "empty double column vector" and I want to receive a numerical value.
0 Kommentare
Antworten (2)
1 Kommentar
Hi @Alyssa Bloomfield,
You asked,”I want to solve for the angles in the overall matrix and get an answer in degrees. If there is more than one solution, I want to be able to see both solutions.”
please see my response to your comments below.
To achieve the desired functionality, you have to enhance the provided MATLAB code which will utilize the Symbolic Math Toolbox to define the rotation matrices for the angles of rotation about the axes and then solve for these angles based on the given numerical matrix (NOA). The final results will be printed in degrees, and will make sure that all possible solutions are displayed.Here is the updated MATLAB code:
% Use Symbolic Math Toolbox syms phi_a phi_o phi_n
% Rotation matrix around the z-axis (T_a) T_a = [cosd(phi_a), -sind(phi_a), 0, 0; sind(phi_a), cosd(phi_a), 0, 0; 0, 0, 1, 0; 0, 0, 0, 1];
% Rotation matrix around the y-axis (T_o) T_o = [cosd(phi_o), 0, sind(phi_o), 0; 0, 1, 0, 0; -sind(phi_o), 0, cosd(phi_o), 0; 0, 0, 0, 1];
% Rotation matrix around the x-axis (T_n) T_n = [1, 0, 0, 0; 0, cosd(phi_n), -sind(phi_n), 0; 0, sind(phi_n), cosd(phi_n), 0; 0, 0, 0, 1];
% Overall Rotation Matrix (RPY) RPY = T_a * T_o * T_n;
% Final Solution Matrix (NOA) NOA = [.7849, -0.1478, .6018, 5; 0.4532, .7992, -0.3948, 8; -0.4226, 0.5826, 0.6943, 2; 0, 0, 0, 1];
% Solve for the angles phi_a, phi_o, and phi_n solutions = solve(NOA == RPY, [phi_a, phi_o, phi_n]);
% Extract solutions and convert to degrees phi_a_solution = double(solutions.phi_a); phi_o_solution = double(solutions.phi_o); phi_n_solution = double(solutions.phi_n);
% Display the solutions disp('Solutions for the angles in degrees:'); disp('phi_a (rotation about z-axis):'); disp(rad2deg(phi_a_solution)); % Convert radians to degrees disp('phi_o (rotation about y-axis):'); disp(rad2deg(phi_o_solution)); % Convert radians to degrees disp('phi_n (rotation about x-axis):'); disp(rad2deg(phi_n_solution)); % Convert radians to degrees
% Check for multiple solutions if length(phi_a_solution) > 1 disp('Multiple solutions found for phi_a:'); disp(rad2deg(phi_a_solution)); end
if length(phi_o_solution) > 1 disp('Multiple solutions found for phi_o:'); disp(rad2deg(phi_o_solution)); end
if length(phi_n_solution) > 1 disp('Multiple solutions found for phi_n:'); disp(rad2deg(phi_n_solution)); end
So, this updated code provides a comprehensive solution to the problem of determining the angles of rotation from a given numerical matrix as mentioned in your comments. Please see attached.
If you have further questions, please let me know.
1 Kommentar
Siehe auch
Kategorien
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!