MATLAB: 2D array

MATLABmatrix

Hi, I have a 3 by 3 matrix X(a,b,c)
I tried to define a submatrix
S = X(3,:,:);
but matlab keeps saying that S is not a 2D array. Why is that so?
Thank you very much.
Added: class(S) apparently is "double" but I don't understand why. How might I make S into a 2D array?

Best Answer

Use squeeze(). This works fine for me:
s3D = rand(4,3,2)
s2D = squeeze(s3D(2,:,:))
s3D(:,:,1) =
0.5103 0.0183 0.1749
0.6590 0.7794 0.2998
0.8773 0.6623 0.7778
0.0790 0.9458 0.6653
s3D(:,:,2) =
0.2475 0.0516 0.3926
0.7406 0.1848 0.6212
0.0042 0.7256 0.4685
0.5316 0.3404 0.1957
s2D =
0.6590 0.7406
0.7794 0.1848
0.2998 0.6212
You can see that it took row 2 out of the first plane, and row 2 out of the second plane, and gave you a 3 by 2 array, just what it should have.