Squish

版本 1.1.0.0 (1.5 KB) 作者: Mirko Hrovat
Squish removes ALL singleton dimensions.
1.4K 次下载
更新时间 2010/2/27

查看许可证

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)))

引用格式

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

MATLAB 版本兼容性
创建方式 R2009b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
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".