Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- « Previous
- Next »

jwscs

Active Participant

07-24-2018 07:19 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

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.

Bob_Schor

Knight of NI

07-24-2018 03:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

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

jamiva

Active Participant

07-25-2018 07:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

@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.

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.

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.

08-03-2018 05:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

Thank you very much. You have understood my problem.

08-10-2018 12:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

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

GerdW

Knight of NI

08-13-2018 12:20 AM - edited 08-13-2018 12:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

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…

Bob_Schor

Knight of NI

08-13-2018 07:29 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report to a Moderator

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

- « Previous
- Next »