| MATLAB Function Reference | Search  Help Desk |
| squeeze | Examples See Also |
B = squeeze(A)
B = squeeze(A)
returns an array B with the same elements as A, but with all singleton dimensions removed. A singleton dimension is any dimension for which size(A,dim) = 1.
Consider the 2-by-1-by-3 array Y = rand(2,1,3). This array has a singleton column dimension -- that is, there's only one column per page.
Y =
Y(:,:,1) = Y(:,:,2) =
0.5194 0.0346
0.8310 0.0535
Y(:,:,3) =
0.5297
0.6711
The command Z = squeeze(Y) yields a 2-by-3 matrix:
Z =
0.5194 0.0346 0.5297
0.8310 0.0535 0.6711
reshape Reshape array
shiftdim Shift dimensions