How to slice a 3D matrix in matlab getting an array
matlab
Solution
squeeze(A(1,:,:))'
works. I think that if I were either smarter or willing to spend more time on this I could do it without a transpose, but this should point you in the right direction.
Problem
Consider having a 3D matrix in matlab where ``` A(:,:,1) = [1 2 3;4 5 6;7 8 9]; A(:,:,2) = [11 22 33;44 55 66;77 88 99]; A(:,:,3) = [111 222 333;444 555 666;777 888 999]; ``` Well when I ask for ``` A(1:end,1,:) ``` I get three different answers: ``` A(1:end,1,1) = [1 2 3]; A(1:end,1,2) = [11 22 33]; A(1:end,1,3) = [111 222 333]; ``` I want to get this in one instruction possibly without cycles and so on: ``` [1 2 3;11 22 33;111 222 333] ``` How to get it? I want a new matrix not a series of vectors. Thankyou.