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 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Kye Taylor
2012년 4월 27일
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
Walter Roberson
2012년 4월 27일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!