Squish

Squish removes ALL singleton dimensions.
1,4K download
Aggiornato 27 feb 2010

Visualizza la licenza

Squish(x) will remove all singleton dimensions in x, including conversion of row vectors to column vectors.

Since singleton dimensions can confuse many operations, this function removes absolutely ALL singleton dimensions. SQUEEZE though similar, does not operate on 2D arrays which include row vectors. Thus the expected result may not always occur with SQUEEZE.

Note: This same operation can be performed with shiftdim(squeeze(x)), but squish has been timed to be faster.

For example compare the results of the following for any positive or negative n:
size(squeeze(shiftdim([1:3]',n)))
size(squish(shiftdim([1:3]',n)))

Cita come

Mirko Hrovat (2024). Squish (https://www.mathworks.com/matlabcentral/fileexchange/11945-squish), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2009b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Matrix Indexing in Help Center e MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.1.0.0

Modified as per Jan Simon's suggestion. It did result in a very very slight speed improvement.

1.0.0.0

Function has been modified to use logical indexing instead of "find".