Eig() matlab coder output

조회 수: 1 (최근 30일)
Arun Agarwal
Arun Agarwal 2020년 5월 20일
답변: Walter Roberson 2020년 5월 20일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 5월 20일
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by