general vector code question

6 views (last 30 days)
random1072 on 16 Apr 2020
Answered: Nikhil Sonavane on 19 May 2020
i have the student matlab with simulink and I am trying to code in the vector components such as V = [A*i + B*j + C*k]. When i type this the i hat and j hat components are automatically recognized as imaginary units however the k hat is not recognized and therefore i cannot compute my vector. Is there a way to code in so the k hat is recognized as a imaginary unit such as i hat and j hat?
random1072 on 16 Apr 2020
trying to make the quaternions q_{1} = [MM, Ai+ Bj+ Ck] and q_{2} = [NN, Di + Ej+ Fk] where A = 7, B = 6, C = 2 , D = 1, E = 6, F = 8, MM = 05, NN = 10.... i dont have the matlab version where i can utilize the quaternion function so not sure how to do this.....after i create the two quaternions i have to add them.

Sign in to comment.

Answers (2)

James Tursa
James Tursa on 7 May 2020
MATLAB does not support the i, j, k quaternion "complex" numbers. The i and j in MATLAB are strictly the ordinary imaginary numbers.
To use quaternions, unless you have special class code for this, typically you would just represent them as ordinary 4-tuples. E.g.,
q_1 = [MM;A;B;C]
q_2 = [NN,D,E,F];
Then if you want to add them it is simple addition:
q_sum = q_1 + q_2;

Nikhil Sonavane
Nikhil Sonavane on 19 May 2020
You may refer the documentation of quaternion for more details.

Community Treasure Hunt

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

Start Hunting!