Assigning variable names to eigenvalues

3 Ansichten (letzte 30 Tage)
JACOB SAMPSELL
JACOB SAMPSELL am 6 Sep. 2021
Kommentiert: Walter Roberson am 7 Sep. 2021
In MATLab,
I am unsure how to take the output from an eigenvalue calculation to then use in another calculation.
For example I input
A = [1 2 3; 1 2 3; 1 2 3];
L = eig(A)
%This is where i need to assign variable names to the eigenvalues returned and order them from largest to smallest.
Thanks!

Antworten (1)

Star Strider
Star Strider am 6 Sep. 2021
Just subscript the original vector to refer to them individually —
format long G
A = [1 2 3; 1 2 3; 1 2 3];
L = eig(A)
L = 3×1
5.99999999999999 -4.46188628311578e-16 -5.6378189834996e-18
format short
L(1)
ans = 6.0000
L(2)
ans = -4.4619e-16
L(3)
ans = -5.6378e-18
.
  1 Kommentar
Walter Roberson
Walter Roberson am 7 Sep. 2021
You could proceed to
E1 = L(1);
E2 = L(2);
E3 = L(3);
but then when you went to order them, it would be far easier to use
sorted_eig = sort(L,'descend')
than it would be to use
if E1 >= E2
if E1 >= E3
sorted_eig = [E1, E2, E3];
else
sorted_eig = [E3, E1, E2];
end
else
... and more tests
end
Putting them into individual variables is Not Helpful for this purpose.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by