Combine matrix (three-in-one)
11 views (last 30 days)
Show older comments
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 Comment
Image Analyst
on 5 Dec 2014
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.
Answers (3)
Star Strider
on 5 Dec 2014
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 Comments
Image Analyst
on 5 Dec 2014
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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!