next up previous contents
Next: Random Number Generation Up: Array Generation and Manipulations Previous: RESHAPE Reshape Array   Contents

Subsections

SQUEEZE Remove Singleton Dimensions of an Array

Usage

This function removes the singleton dimensions of an array. The syntax for its use is

   y = squeeze(x)

where x is a multidimensional array. Generally speaking, if x is of size d1 x 1 x d2 x ..., then squeeze(x) is of size d1 x d2 x ..., i.e., each dimension of x that was singular (size 1) is squeezed out.

Example

Here is a many dimensioned, ungainly array, both before and after squeezing;

--> x = zeros(1,4,3,1,1,2);
--> size(x)
ans = 
  <uint32>  - size: [1 6]
 
Columns 1 to 5
            1             4             3             1             1  
 
Columns 6 to 6
            2  
--> y = squeeze(x);
--> size(y)
ans = 
  <uint32>  - size: [1 3]
 
Columns 1 to 3
            4             3             2



Samit K. Basu 2005-03-16