Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.0.0 - 日本語


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 — ベクトルまたは行列を異なる大きさの行列に成形する
  • hypermatrices — Scilab オブジェクト, Scilabの N 次元行列
Report an issue
<< resize_matrix matrixmanipulation 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:
Tue Mar 07 09:28:42 CET 2023