Eig() matlab coder output

5 Ansichten (letzte 30 Tage)
Arun Agarwal
Arun Agarwal am 20 Mai 2020
Beantwortet: Walter Roberson am 20 Mai 2020
I have used the eig() function in matlab and obtained the V(Eigen vector) and D(eigen value).
Matlab output
0.491577650531798 -0.495336899750405 -0.716235135443169
0.503488034360681 -0.509405143984653 0.697858294023645
-0.710528826124074 -0.703667361064609 -0.00101598184714255
after using the matlab coder to convert this function to C, I'm getting a different eigen vector and value as the output. There is a change of sign.
C code array output - Comes in real and imaginary for which a workaround was found.
V = {-0.716235135443169, 0.697858294023645, -0.00101598184714255, 0.495336899750405, 0.509405143984653, 0.703667361064609, -0.491577650531798, -0.503488034360681, 0.710528826124074}
D = {0, 0, 81386639.3671520, 0, 256256.510446245, 0, 322.189392401933, 0, 0};
Is there any solution for this ? the output in C code seems to change the polarity randomly for different data.

Antworten (1)

Walter Roberson
Walter Roberson am 20 Mai 2020
eigenvectors are not unique; if V is an eigenvector of the matrix, then c*V is also an eigenvector of the matrix, where c is a non-zero scalar. In particular, if V is an eigenvector of the matrix, then -V is an eigenvector of the matrix.
It is common for people to normalize by taking the negative of the vector if the first non-zero element in the vector is negative.

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by