compute eigen values of a matrix with symbolic variable

1 回表示 (過去 30 日間)
Thayumanavan
Thayumanavan 2014 年 2 月 12 日
コメント済み: Thayumanavan 2014 年 2 月 15 日
%The code is :
syms A ;
matrix = [A, (2*A)-1; 4*A, 2*A];
A = 1.0;
matrix
subs(matrix, A,1)
A
% reset(symengine)
matrix
eig(matrix)
I want to compute the eigen values of a matrix filled with symbolic variable A. I used
1. reset(symengine) option
2. subs(matrix, A,1)
but i am getting the answer with symbolic variable only as follows:
(3*A)/2 - (33*A^2 - 16*A)^(1/2)/2
(3*A)/2 + (33*A^2 - 16*A)^(1/2)/2
But i want the answer(eigen values of matrix ) as
matrix=[1 1;4 2];
eig(matrix)
-0.5616
3.5616
Please help in this regard.

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 2 月 12 日
subs(matrix, A, 1) does not change matrix: it produces a new value with the substitution made.
eig(double(subs(matrix, A,1)))
  1 件のコメント
Thayumanavan
Thayumanavan 2014 年 2 月 15 日
For this code i got Error in MuPAD command: DOUBLE cannot convert the input expression into a double array. but i changed double to vpa i got the answer .
eig(vpa(subs(matrix, A,1))) (or) eig(eval(matrix)). Thank you

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

Community Treasure Hunt

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

Start Hunting!

Translated by