An issue with eigenvectors...

2 ビュー (過去 30 日間)
Santiago Piñon
Santiago Piñon 2022 年 11 月 27 日
コメント済み: Santiago Piñon 2022 年 11 月 27 日
When i execute this it only shows the last vector, not the first or second one.
clc
clear variables;
prompt = ("Ingrese su matriz de coeficientes ");
w=input(prompt);
fprintf("La matriz ingresada es\n");
disp(w)
sz=size(w);
tm=sz(1,1);
p=round(poly(w));
e = eig(w);
fprintf('**Los valores propios del sistema son: \n');
disp(e);
v1=e(1,1);
v2=e(2,1);
v3=e(3,1);
tf=isreal(e);
if(tf==1)
fprintf('**Los vectores propios del sistema son: \n');
L1=null(w-(v1*eye(tm)), 'r');
disp(L1);
L2=null(w-(v2*eye(tm)), 'r');
disp(L2);
L3=null(w-(v3*eye(tm)), 'r');
disp(L3);

回答 (1 件)

Bruno Luong
Bruno Luong 2022 年 11 月 27 日
Remove the rational option "r" (not reliable) you'll be fine
w = magic(3)
w = 3×3
8 1 6 3 5 7 4 9 2
disp(w)
8 1 6 3 5 7 4 9 2
sz=size(w);
tm=sz(1,1);
p=round(poly(w));
e = eig(w);
fprintf('**Los valores propios del sistema son: \n');
**Los valores propios del sistema son:
disp(e);
15.0000 4.8990 -4.8990
v1=e(1,1);
v2=e(2,1);
v3=e(3,1);
tf=isreal(e);
if(tf==1)
fprintf('**Los vectores propios del sistema son: \n');
L1=null(w-(v1*eye(tm)));
disp(L1);
L2=null(w-(v2*eye(tm)));
disp(L2);
L3=null(w-(v3*eye(tm)));
disp(L3);
end
**Los vectores propios del sistema son:
0.5774 0.5774 0.5774
-0.8131 0.4714 0.3416
-0.3416 -0.4714 0.8131
  3 件のコメント
Bruno Luong
Bruno Luong 2022 年 11 月 27 日
編集済み: Bruno Luong 2022 年 11 月 27 日
No "r" is NOT correct in general, as stated by the offiial doc page
Z = null(A,"rational") returns a rational basis for the null space of A that is typically not orthonormal. If A is a small matrix with small integer elements, then the elements of Z are ratios of small integers. This method is numerically less accurate than null(A).
It is just a toy option forr students who works with academic examples. That's why it fails to return the eigen vector randomly.
Santiago Piñon
Santiago Piñon 2022 年 11 月 27 日
I see, thank you very much, sorry if i sounded rude.

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

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by