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.

1 view (last 30 days)
Here is my code:
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)
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.

Answers (2)

Kye Taylor
Kye Taylor on 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.

Walter Roberson
Walter Roberson on 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.


Find more on Matrices and Arrays 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!