I have the X,Y,Z and W components of a Quaternion through time, in 4 separated vectors.
QW 1x346 2768 double
QX 1x346 2768 double
QY 1x346 2768 double
QZ 1x346 2768 double
I want to convert to euler angles in order to plot the 3 euler components in three different subplots through time, so I need to have 3 vectors like these.
heading(t) 1x346
attitude(t) 1x346
bank(t) 1x346
Is there an inmediate way in matlab to get this (I mean a function with input my 4 vectors and output the above 3 vectors) or do I have to write some code to make the conversion for each timestep? Thanks in advance.
I do not think there is a built in Matlab function to perform what you want.
However, there is a function in the Mathworks user community which I believe is what you are looking for. spinCalc This will convert between the various rotation types DCM, Euler angles, Euler vectors, and Quaternions.
Please note this comment from the above post regarding Euler Angle Sets and which rotation sequence you are using.
When converting data to Euler angles, you MUST make sure the orientation you are translating is not near a singularity. Singular Euler sets are orientations which cannot be uniquely converted to 3 variables in that particular rotation order. The singular sets are as follows:
Type 1 Rotations: 123 - 132 - 213 - 231 - 321 - 312 Singular if second rotation angle is -90 or 90 degrees.
Type 2 Rotations: 121 - 131 - 212 - 232 - 313 - 323 Singular if second rotation angle is 0 or 180 degrees.