Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
您如何阅读以下MATLAB代码?
#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 回答: 在第二种情况下, p,d=eig(A) MATLAB仅打印情况1中先前计算的p值,然后运行命令d=eig(A) 。 在运行案例2之前,请尝试 >> clear pd 如果然后运行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() 更多&回答... |
![]() |
![]() |