Attempt to have a 3D mesh plot of max value of real part of eigenvalues of a matrix. Shows error saying that 'Error showing Horzcat. CAT arguments dimensions are not consistent' even though my matrix is square.
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Here is my code:
[B,k]=meshgrid(0:0.01:10);
BKm= [0, 1, 0, 0, 0, 0;
(-0.0517428 *k-0.444277), (-0.260491), (0.112669 *k+0.135935), (0.711674), (-0.12895 *k-1.63146), (-0.711674);
0, 0, 0, 1, 0, 0;
(0.141364 *k+1.21379), (0.711674), (0.0374225-0.294178 *k), (-1.94433), (0.325021 *k+3.63963), (1.94433);
0, 0, 0, 0, 0, 1;
(-0.141364 *k-1.21379), (-0.711674), (0.270554 *k-0.745489), (1.94433), (-0.301397 *k-2.93156), (-1.94433)
];
EV=eig(BKm);
Eigmax=max(real(EV));
surf(k,B,BKm)
And the error:
Error using horzcat
CAT arguments dimensions are not consistent.
I am attempting to plot the maximum of real parts of all eigenvalues available for this matrix in a 3D contour sort of plot. Even though my matrix seems square to me, I am getting this error. Please help. Thanks in advance.
0 Kommentare
Antworten (2)
Kye Taylor
am 27 Apr. 2012
When you create BKm, you use the output k from meshgrid. The output k is a 1001 square matrix that you are effectively trying to use as a scalar in the definition of BKm.
If k were a scalar, BKm would be a 6-by-6 square matrix so the surf command won't work unless BKm is the same size as k, which must also be the same size as B in order for surf() to work.
0 Kommentare
Walter Roberson
am 27 Apr. 2012
k is 1001 by 1001. a*k+b with a and b scalar would then be 1001 x 1001. You then try to horzcat a 1 x 1 scalar -0.260491 with that (second line of matrix). Dimension problems.
What are you trying to do, create a 4D matrix, 6 x 6 x 1001 x 1001 ? If you do, you will not be able to eig() that matrix.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!