how to concatenation matrices
이전 댓글 표시
I tried to execute this which is part of a program i got this error message on the Q1 line(2nd line):
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.Please any hint on what to do to correct it?
P1 =[P111 P112; P121 P122];
Q1=[Q111 Q112; Q121 Q122];
V=[V11 V12 ; V21 V22];
Q2=[Q211 Q212 ; Q221 Q222];
P2 = [P211 P212; P221 P222];
W = (P1*Q1*V*Q2*P2);
댓글 수: 8
Andrew Newell
2015년 1월 9일
Are the arguments like P111 all scalars?
dpb
2015년 1월 9일
Clearly not; otherwise there would be no size mismatch.
And when OP gets taht sorted out, then undoubtedly there will be a needed "dot" operator on the last line.
Amos
2015년 1월 9일
Segun, in order to see what is going on, we need you to add the part of your code where Q111, Q112, Q121 and Q122 are defined, or, alternatively, check the dimension of these sub matrices by the command size(Q111) and so on.
segun
2015년 1월 11일
Image Analyst
2015년 1월 11일
Did you see my answer about learning how to use the "whos" command and how to use the debugger??? Clearly everything is not 2-by-2 or it wouldn't give that error. And since you won't give us the complete code, like how the P111 etc. are created, you're on your own.
Image Analyst
2015년 1월 13일
It's not the whole code. Why do you make it difficult for us to help you? Please read this. The code is not formatted. Once I fixed that, there was an extra end in there. Once I fixed that, it said f was not define (a different error than you're asking about). After that I gave up.
답변 (1개)
Image Analyst
2015년 1월 10일
0 개 추천
You are kidding me. Don't tell me you've been working on this since last July and still don't have a solution that works yet. http://www.mathworks.com/matlabcentral/answers/141425-syntax-to-multiply-two-by-two-matrices-with-zeros-in-it-with-numbers
Why not just learn how to debug http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/, or, worst case, just put a bunch of "whos" commands in there to find out what the rows and columns of all your arrays are. If you stitch together horizontally, they must have the same number of rows. If you stitch together vertically, they must have the same number of rows.
댓글 수: 1
Stephen23
2015년 1월 10일
Small correction: "If you stitch together horizontally, they must have the same number of rows. If you stitch together vertically, they must have the same number of columns".
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!