Question: Write a function that takes in a 1-row cell of, or strings, and returns a 1-row cell array whose elements are the three-dimensional unit vectors

 Write a function that takes in a 1-row cell of, or

strings, and returns a 1-row cell array whose elements are the three-dimensional

Write a function that takes in a 1-row cell of, or strings, and returns a 1-row cell array whose elements are the three-dimensional unit vectors pointing in the corresponding directions Function e Reset DE MATLAB Documentation 1 function joint_axis_vectors = threed_joint_axis_setjoint_axes) 2 * Generate a set of unit vectors along specified x, y, or z axe5 4 % Input: 59 6 % joint_axes: a cell array, each element of which is a one-character string 'X', 'y', or 'z' that specifies B% an axis of rotation 99 19 % Output: 12 % joint_axis_vectors: a cell array of the same size as the vector joint_axes, in which each cell contains the unit vector in the direction specified in the corresponding entry of joint_axes * Start by creating an empty cell array of the same size as joint_angles, % named 'joint_axis_vectors' 15 16 17 1B 19 29 21 22 23 24 25 Loop over the joint axes 4 Use 'switch/case' to check which axis the joint is aligned with 4s around. For 'x', 'y', or 'z', this should result in a unit vector % along the appropriate axis. 26 27 28 29 $ Any other string should trigger the 'otherwise' part of $ switch/case, in which there should be an 'error' function that s tells the user what they did wrong. For example, 30 31 32 $error[joint_axis' is not a known joint axis']) 31 B % TELLS Ule user wird ey UIU WTUTTG. Tor example, 31 32 errori (joint_axis ' is not a known joint axis']) '] 33 34 would make the program stop, and tell the user what string was 35 incorrectly supplied as the description of a rotation matrix. 36 s={'X', 'y', 'z'}; 37 for idx = 1: numelis) 38 S{idx} 39 end 40 if(joint_axes=='') 41 n=1; 42 elseif (joint_axes=='y') 43 n=2; 44 else 45 n=3; 46 end 47 switch cases 48 switch n 49 case 1 58 Rset=[1 0 0;0 cosdjoint_angles) -sind(joint_angles); 8 sind joint_angles) -cosdijoint_angles)]; 51 case 2 52 Rset=[cosdjoint_angles) -sind joint_angles);0 1 0;sind joint_angles) 0 -cosdijoint_angles)]; 53 case 3 54 Rset=[cosdjoint_angles) -sind (joint_angles) 0; sind (joint_angles) -cosd joint_angles) 0; 1); 55 otherwise 56 end 57 58 end Code to call your function C Roset 1. This code generates a set of three rotation matrices 2 3 s = threeD_joint_axis_set({'X', 'y','z'}) 4 s{:}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!