Clear Filters
Clear Filters

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 views (last 30 days)
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)

Answers (1)

Bhanu Prakash
Bhanu Prakash on 16 Apr 2023
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.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!