Plotting eigenvalues of a 4*4 matrix: In an assignment A(I) = B, the number of elements in B and I must be the same.
7 次查看(过去 30 天)
显示 更早的评论
p=1;
for k=0.1:.1:3
A=[0 0 0 exp(-i*k);exp(i*k) 0 0 0;0 exp(i*k) 0 0;0 0 exp(i*k) 0];
C=eig(A);
x(p)=k;
y(p)=C;
p=p+1;
end
plot(x,y)
0 个评论
回答(1 个)
Bhanu Prakash
2023-4-16
Hi Zahid,
As per my understanding, you are trying to plot the eigen values of a 4x4 matrix and are facing some error with it.
To perform an assignment operation, the dimensions of the matrices must be equal. For any given iteration, the matrices "C" & "y" have the dimensions 4x1 & 1x1 respectively, making the dimensions incompatible.
One workaround for this, is to change the indices of the matrix "y" as shown below:
y(:,p)=C;
You can refer to the documentation of array indexing, for more info:
Hope this answer helps you.
Thanks,
Bhanu Prakash.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Octave 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!