made a code in matlab which includes functions like rand, eig, cov and many more. I want to convert the same to HDL, but cannot due to those functions.

7 views (last 30 days)
hello, Can anyone tell me how to find out eigen values and eigen vectors of large matrix of order 10x10 or more, without using the function 'eig', so that it becomes convertible to HDL using HDL converter?

Accepted Answer

John D'Errico
John D'Errico on 16 Sep 2016
Edited: John D'Errico on 16 Sep 2016
10x10 is not a large problem. :) In fact, 10 is pretty small. That does not mean it is trivial for any general matrix, and the simplest solution may depend on some characteristics of your matrix. Is it real and symmetric for example? Is it positive definite?
You can reduce an eigenvalue computation into one of finding the roots of a polynomial. Or you can use the power method on some matrices. (Be careful if an eigenvalue has degree greater than 1, etc.)
And tools like cov are easily written as not much more than subtracting a mean followed by a matrix multiplication.

More Answers (2)

Tim McBrayer
Tim McBrayer on 16 Sep 2016
You will need to decompose the computation of eigenvectors to more basic operations and organize these in a way that meets your hardware requirements for size and speed. There are a huge number of ways to accomplish this, which is one reason why eig() is not directly supported by HDL Coder.

Walter Roberson
Walter Roberson on 17 Sep 2016
It is possible to generate the characteristic polynomial of the 10 x 10 matrix in a symbolic form. It would be quite large, but it is possible.
You would then be left trying to find the roots of that 10 degree polynomial. There is no algebraic solution for finding the roots of a general polynomial of degree 5 or higher. You could resort to using roots() on that long polynomial, but roots() invokes eig...
So, you are pretty much going to need to work numerically using some algorithm or other. https://www.mathworks.com/moler/eigs.pdf
  2 Comments
Sukhmani Kaur Thethi
Sukhmani Kaur Thethi on 17 Sep 2016
sir, actually this is the minimum matrix dimension. I need to work on bigger matrix dimensions. will the QR method work then? will I get all the eigen values and eigen vectors using that method?
Walter Roberson
Walter Roberson on 17 Sep 2016
It looks to me as if SVD might make more sense then QR for you.
However, an important question here is whether those random matrices you are producing are symmetric or not. If they are not, then complex eigenvalues are to be expected, which complicates the algorithm and the generated HDL.
Checking, I see that code generation is supported for eig(), at least at the MATLAB level.
What is it that you are doing, that eigenvalues of random matrices makes sense?

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!