Reputation: 141180
How do you read the following MATLAB codes?
K>> [p,d]=eig(A) // Not sure about the syntax.
p =
0.5257 -0.8507
-0.8507 -0.5257
d = // Why do you get a matrix?
0.3820 0
0 2.6180
K>> p,d=eig(A) // Not sure about the syntax.
p =
0.5257 -0.8507
-0.8507 -0.5257
d = // Why do you get a vector?
0.3820
2.6180
where
A =
2 1
1 1
Upvotes: 1
Views: 393
Reputation: 3306
In your second case p,d=eig(A)
MATLAB is merely printing the previously calculated value of p from case 1 and then running the command d=eig(A)
.
Before running case 2 try
>> clear p d
If you then run p,d=eig(A)
it will return an error saying that p is undefined function or variable.
From help eig
:
E = EIG(X) is a vector containing the eigenvalues of a square
matrix X.
[V,D] = EIG(X) produces a diagonal matrix D of eigenvalues and a
full matrix V whose columns are the corresponding eigenvectors so
that X*V = V*D.
Note there is no V,D = EIG(X)
option. MATLAB functions that return more than one value will group them using the format:
[ ] = function()
Upvotes: 18