Building a quaternion in Matlab using "engine.h" from C ++

I have an algorithm in C ++ that uses a Kalman filter. Somewhere in the code, the quaternion q 'is predicted, and then I update the Quaternion using the Kalman q filter.

I want to build two graphs in Matlab with the evolution of the predicted quaternion and the corrected (updated) quaternion, so I use the "engine.h" library to send information about the quaternion to Matlab during processing (in fact, what I'm sending is 4x1) .

So my question is : What is the best way to build a quaternion in Matlab so that I can visually extract information? Maybe it’s better to build charts separately?

+4
source share
2 answers

I think a good option sends quaternion as a vector in MATLAB using the C ++ MATLAB engine

[qx qy qz qw]

Then in MATLAB, you can use the toolbox to translate to Euler Angles, which is a common visual option.

To add a toolbar path in the matlab module:

addpath(genpath('C:\Program Files (x86)\MATLAB\R2010a\toolbox\SpinCalc')); 

With the spincalc toolbox, the conversion would be something like this:

 Angles=SpinCalc('QtoEA321',Quaternion,0,0); 
+4
source

Well, assuming the question is β€œhow to imagine 4D space well,” I can come up with several options:

  • Show several pieces of space, i.e. for (x, y, z, t) β†’ (x, y), (y, z), etc.
  • Show (x, y) as a scatter plot and encode z information in color, t in dot size. To do this, you can use the Scatter command:

SCATTER (X, Y, S, C) displays the colored circles in the indicated places by the vectors X and Y (which should be the same size).

If you have a question: "How to visualize a quarter in good terms, check this out.

+4
source

Source: https://habr.com/ru/post/1390387/


All Articles