# how to multiply quaternion wth 1x3 vector

3 views (last 30 days)
zeynep ozkayikci on 23 Aug 2022
Edited: James Tursa on 23 Aug 2022
I have " BECI [3x1] Mag. Field Component vector " ı am trying to multiply with quaternion but it gives dimension error. Should ı change my vector to quaternion. how could ı do?
quatprod = quatmultiply(qb2inv,BECI)

James Tursa on 23 Aug 2022
Edited: James Tursa on 23 Aug 2022
Use BECI as the "vector" part of a quaternion and put a 0 in the "scalar" part, and use that new quaternion in the multiply. Since MATLAB stores the "scalar" part as the 1st element of the quaternion, that means your new 1x4 quaternion will have a 0 in the 1st spot. E.g., assuming BECI is 1x3 you would have:
QBECI = [0,BECI];
then
quatprod = quatmultiply(qb2inv,QBECI)
quatmultiply( ) should be smart enough to do this on its own, but it isn't. You could also write a little function to do this in the background for you which would then in turn call quatmultiply( ).
If this is part of a rotation multiply sequence such as q^-1 * v * q or q * v * q^-1, then again start with [0,v] instead of just v, and then pick off the vector part of the final result (the last three elements). The scalar part of the result will probably not be exactly 0 because of floating point arithmetic effects, but this can be ignored.
You might be insterested in this post also:

### Categories

Find more on Coordinate Transformations and Trajectories in Help Center and File Exchange

R2019b

### Community Treasure Hunt

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

Start Hunting!