quat2dcm function error message

Hello,
I'm new to the use of these types of functions to transform from one reference frame into another and trying to go from a set of quaternions to a DCM reference frame. However, when trying to use any of the axis transformation functions from quaternions, I get the error message below to say 'input elements are not real'. I can, however, convert to euler angles understandably.
I do not understand why the input elements would not be 'real' since they are simply a set of quaternions derived from accelerometer and gyroscope readings.
Any help much appreciated. Thanks in advance.
dcm = quat2dcm(Q);
Error using quatmod (line 19)
Input elements are not real.
Error in quatnormalize (line 19)
qout = q./(quatmod( q )* ones(1,4));
Error in quat2dcm (line 24)
qin = quatnormalize( q );

5 comentarios

please show
whos q
Tinman
Tinman el 28 de Ag. de 2022
So 'Q' is a 400x1 quaternion
I do not know what 'q' is or how that works it's way into the function because that just came out as a result of using quat2dcm
Tinman
Tinman el 28 de Ag. de 2022
From the MATLAB help:
"n = quatnormalize(q) calculates the normalized quaternion, n, for a given quaternion, q. Input q is an m-by-4 matrix containing m quaternions. n returns an m-by-4 matrix of normalized quaternions. Each element of q must be a real number."
However:
1. I'm not sure if the m-by-4 matrix is going in correctly although I presumed that's what the function converted my quaternion data into as it goes through the transmformation
2. I don't understand why I am being told the elements aren't real, assuming that the indication there is that they are not 'real numbers'.
Walter Roberson
Walter Roberson el 28 de Ag. de 2022
Editada: Walter Roberson el 28 de Ag. de 2022
Please show the output of
whos Q
I don't understand why I am being told the elements aren't real, assuming that the indication there is that they are not 'real numbers'.
Because it gives the same error message if the input is not class double(), and possibly if it is not an N x 4 matrix of double.
Tinman
Tinman el 30 de Ag. de 2022
I thought the easiest way here might be to screenshot.
Each quaternion is contained in a 1x1 within the 400x1 matrix for 'Q'. Is the issue that the 4 values within the quaterion should be expressed across the matrix?

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Ag. de 2022
Editada: Walter Roberson el 30 de Ag. de 2022

0 votos

Input arguments
q: Quaternion, specified as an m-by-4 matrix containing m quaternions. Each element of q must be a real number. double
That means that the function requires an m x 4 array of double. It does not support quaternion objects. The error message is because isdouble() is false for quaternion() class objects.
You must extract the data from your quaternion() objects to use this function.

1 comentario

Tinman
Tinman el 30 de Ag. de 2022
matrix = compact(quat) converts the quaternion array, quat, to an N-by-4 matrix.
Did the trick! Thanks again.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2021b

Preguntada:

el 28 de Ag. de 2022

Editada:

el 30 de Ag. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by