I have to calculate the eigen vector and eigenvalues & i write a code and use the eig() function but it shows some error such as Undefined function 'eig' for input arguments of type 'double' and attributes 'full 3d real', please help.Code are below

Matrix = imread('uz.jpg');
%Convert image to double precision to use eig function:
imtype = class(Matrix);
Matrix = double(Matrix);
%Find a square matrix that fits image for eig operation:
sz = size(Matrix);
m = max(sz);
mx = zeros(m, m,3);
mx(1:sz(1),1:sz(2),1:sz(3)) = Matrix
%Find eigenvectors and eigenvalues:
[V, D] = eig(mx)
%check that the matrix generates A using matrix factorization and convert back to original image:
eval(['A = ',imtype,'(abs(V*D*V^(-1)));']);
figure
imshow(A)

1 件のコメント

You don't need eval() and class() to compute and cast A. Using eval() is not recommended. Just use cast():
A = cast(someMatrixToConvert, class(Matrix));

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2014 年 9 月 7 日
Your mx matrix is 3-dimensional. You can only take eigenvalues and eigenvectors of a square (NxN) matrix.

2 件のコメント

The point is, you need to think about what it you intend when you try to compute the eigenvalues of an image. There are three channels in an image. Until you decide what you are trying to do, and think about how you must approach it in a way that is mathematically valid, eig will/must fail.
Stephen23
Stephen23 2014 年 9 月 7 日
To this end it could be worth revising the definition of eigenvectors and eigenvalues, and then think about the code: understanding the problem is just as important as solving it.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

質問済み:

2014 年 9 月 7 日

コメント済み:

2014 年 9 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by