Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - English


squeeze

removes singleton dimensions of a ND-array

Syntax

r = squeeze(hypIn)

Arguments

hypIn

a ND-array of any native type (boolean, .., cells, structures)

r

an array or ND-array of the same type.

Description

squeeze(…) removes singleton dimensions of an hypermatrix or ND-array, that is any dimension for which the size is 1. If the input hypIn is a matrix, it is returned as is.

Scilab squeezes highest singleton dimensions automatically.

Examples

// For 2D input matrices => no action
u = squeeze(ones(1,4))
size(u)

// auto-squeezing of highest singleton dimensions:
v = ones(2,3,1,1);
size(v)

// For an actual input ND-array:
w = squeeze(ones(1,3,1,4))
size(w)

// for a 4D-array of cells
c = cat(4, {%t}, {%pi}, {"abc"});
size(c)
x = squeeze(c)
size(x)
--> u = squeeze(ones(1,4))
 u  =
   1.   1.   1.   1.

--> size(u)
 ans  =
   1.   4.

--> // auto-squeezing of highest singleton dimensions:
--> v = ones(2,3,1,1);
--> size(v)
 ans  =
   2.   3.

--> // For an actual input ND-array:
--> w = squeeze(ones(1,3,1,4))
 w  =
   1.   1.   1.   1.
   1.   1.   1.   1.
   1.   1.   1.   1.

--> size(w)
 ans  =
   3.   4.


--> // for a 4D-array of cells
--> c = cat(4, {%t}, {%pi}, {"abc"});
--> size(c)
 ans  =
   1.   1.   1.   3.

--> x = squeeze(c)
 x  =
  [1x1 boolean ]
  [1x1 constant]
  [1x1 string  ]

--> size(x)
 ans  =
   3.   1.

See also

  • matrix — reshapes an array with the same number and order of components
  • hypermatrices — a Scilab object, N dimensional matrix in Scilab
Report an issue
<< resize_matrix Matrix - shaping tril >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Mar 27 11:52:42 GMT 2023