2009-11-13 71 views
1

你如何閱讀以下代碼MATLABMATLAB的矩陣符號之間的區別

#1

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 

#2

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 

其中

A = 

    2  1 
    1  1 
+0

你似乎越來越和Lua符號混淆。 – 2009-11-15 09:52:56

回答

18

在第二個情況下p,d=eig(A)MATLAB僅僅從殼體1,然後打印p的先前計算的值運行命令d=eig(A)

運行的情況下2之前嘗試

如果你再運行p,d=eig(A)它會返回一個錯誤,說p是未定義的函數或變量。

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. 

注意沒有V,D = EIG(X)選項。返回他們使用的格式不止一個值將組MATLAB功能:

[ ] = function() 
3
p,d=eig(A) 

相同

p 
d=eig(A)