Combine matrix (three-in-one)
조회 수: 11 (최근 30일)
이전 댓글 표시
I have three matrix : x,y,z
X =
- X11 X12 X13
- X21 X22 X23
- X31 X32 X33
Y=
- Y11 Y12 Y13
- Y21 Y22 Y23
- Y31 Y32 Y33
Z=
- Z11 Z12 Z13
- Z21 Z22 Z23
- Z31 Z32 Z33
How i can combine this matrix, for this result:
P=
- X11 Y11 Z11
- X12 Y12 Z12
- X13 Y13 Z13 and etc..
Please help me
댓글 수: 1
Image Analyst
2014년 12월 5일
Explain what "and etc." means. Aren't you just making the columns of P the first row of X, Y, and Z? So what "etc." could there be? Please clarify/expand in case we need to modify our answers.
답변 (3개)
Star Strider
2014년 12월 5일
This is done symbolically for illustration, but the permute function is likely what you want:
X = sym('X%d%d',[3 3]);
Y = sym('Y%d%d',[3 3]);
Z = sym('Z%d%d',[3 3]);
P(:,:,1) = X;
P(:,:,2) = Y;
P(:,:,3) = Z;
P1 = permute(P, [2 3 1])
produces:
P1(:,:,1) =
[ X11, Y11, Z11]
[ X12, Y12, Z12]
[ X13, Y13, Z13]
P1(:,:,2) =
[ X21, Y21, Z21]
[ X22, Y22, Z22]
[ X23, Y23, Z23]
P1(:,:,3) =
[ X31, Y31, Z31]
[ X32, Y32, Z32]
[ X33, Y33, Z33]
댓글 수: 0
Image Analyst
2014년 12월 5일
To put the first rows of the 3 matrices as the columns of a new matrix P, do this:
P = [X(1,:)', Y(1,:)', Z(1,:)']
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!