MATLAB Answers

how to get eigenvalues of a function matrix?

1 view (last 30 days)
hi
suppose we have with function H=@(x)[x/2,0,0,0;0,-x/2,x,0;0,x,-x/2,0;0,0,0,x/2];
how to get igenvalues and igenvectors of this matrix? eig(H) gives this error ==> Undefined function 'eig' for input arguments of type
'function_handle'.
what i can to do ? plz help me

  0 Comments

Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 20 Dec 2019
To calculate the eigenvalues of H you have to chose, either to use your implementation where H is a handle to a function returning an ordinary matrix if you feed it an input argument. This for example works fine:
eig(H(3))
Since:
H(3)
returns a matrix:
ans =
1.5000 0 0 0
0 -1.5000 3.0000 0
0 3.0000 -1.5000 0
0 0 0 1.5000
That has some eigenvalues. Or you could go with symbolic calculations:
syms x;
eig([x/2,0,0,0;0,-x/2,x,0;0,x,-x/2,0;0,0,0,x/2])

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.