LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

eigenvalues and vectors

i think gerd's question was to make sure, that its not a miniscule difference,

coming from the different implementations of the algorithms in matlab/labview.

 

as a way to verify your algorithm, implement a mockup, with a defined small input matrix, for which you can even calcuclate/verify by hand and compare this with matalab.

 

describing what you want to do in a mathematical way might also be helpful.

so it may become easier to verify the correctness of your labview algorithm.

 

regards

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 21 of 27
(903 Views)

I did the following experiment (which I invite you to do, as well):

  • I generated a lot (5000) of points whose X and Y coordinates were chosen as to be normally distributed with mean 0 and standard deviation 1.  When plotted, it looked like a "ball of dots" arou
  • I "stretched" this in the X direction by a factor of 4.  I got an elliptical "cloud".
  • I calculated the variance of the X components -- it was 16 (more or less -- these are random dots ...).
  • I took the Eigenvalues of the Covariance Matrix, and got Eigenvalues of 16 (correct) and 1 (also correct).

Quoting from "What does eigenvalues expres in the covariance matrix" (not my spelling!) question in the Matlab Forums, "observe the eigenvalues of the covariance matrix are equal to the variance of the data's coordinates".

 

When I calculate the Eigenvalues of the Covariance matrix, I get the Variance of the data's coordinates, which is what the Matlab Forum suggests should be expected.  When you calculate something related to the Correlation (not Covariance) matrix, you get something else.  This does not say anything about Matlab's or LabVIEW's Eigenvalue functions.

 

Bob Schor

0 Kudos
Message 22 of 27
(891 Views)

@canzie07 wrote:

the command for eigenvalues and vectors of the single matrix gives the different result when compared with the Matlab command for the same. please solve the doubt.


I'm not commenting on the science behind the experiment, but of the OP's original question, that the results are not the same between LabVIEW and Matlab. I'm not a mathematician nor expert in Linear Algebra but here is what I think is going on.
 
I compared the results for several 3x3 matrices, and shown here is a snippet of the results for the OP's "all_nor325_25_600" file using LabVIEW and Matlab.

 

LabVIEW Reults_Normal.PNG

 

 

Matlab Reults_Normal.PNG

 

The results for each column are the same up to 15 significant digits with the following 2 exceptions:
 
  1. The sort order of the eigenvector/eigenvalue pairs are not the same. It appears that LabVIEW sorts the pairs by decreasing eigenvalues, and Matlab sorts them by increasing eigenvalues.
 
  2. Some of the eigenvector columns are scaled by a factor of -1.
 
My understanding is that the eigenvector is a column vector, and each eigenvector is paired with its corresponding eigenvalue. There is no implied sort order for the complete set of eigenvector/eigenvalue pairs. They all satisfy the equation A*x = lamda*x. Changing the sign of each element of an eigenvector has the same effect as multiplying both side of the equation by -1 so the relationship for a linear system still is true (-A*x = -lambda*x). I believe is would also be true for ANY constant scale factor for the eigenvectors.

 

help.PNG

 

The bottom line is that the OP is indexing the eigenvector matrix to a specific column in his LabVIEW vi. That column is most likely not the same as the column in the Matlab matrix.

Message 23 of 27
(880 Views)

Thank you very much. You have understood my problem.

0 Kudos
Message 24 of 27
(859 Views)

I haven't understood properly.But please help me find some solution.It's very urgent.

0 Kudos
Message 25 of 27
(835 Views)

Hi canzie,

 

I haven't understood properly.

What exactly didn't you understand?

 

But please help me find some solution.

See message #23 for a solution!

 

It's very urgent.

Well, nearly 3 weeks after the solution was presented: can't be that urgent…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 26 of 27
(816 Views)

Canzie,

 

     I have tried to convince you that LabVIEW is returning the correct answers to the problem of finding the Principle Components of a set of covarying data, sorted with the largest Component first (makes sense to me!).  I don't have Matlab currently available, so was unable to confirm that Matlab produced the same results with this data.

 

     GerdW did a direct LabVIEW-to-Matlab comparison, and seemed to find that both systems gave the same results (to within rounding errors), but perhaps in different orders and/or with the sign of the Eigenvector components reversed (which doesn't change the math).

 

     So why are you still asking questions?  It appears that LabVIEW and Matlab give the same results, but may format them differently, may have confused you by their computation conventions, etc.  As GerdW says, it's been three weeks that this "urgent" problem has been bugging you, but the answer seems to be "there's no problem here, only one of perception".  If you still don't get it, go find your instructor, show him/her this Forum conversation, and say "I still don't get it, please help me understand" ...

 

Bob Schor

0 Kudos
Message 27 of 27
(802 Views)