How does Squeeze work?
显示 更早的评论
Hello all,
Can anybody explain me what Squeeze is used for? I have read about it in MATLAB help but I am still confused !
Thanks a lot :-)
采纳的回答
更多回答(1 个)
James Tursa
2011-5-1
3 个投票
The squeeze function is similar to reshape in that it changes the dimensions of a variable without moving any of the data in memory. The total number of elements and their ordering in memory remain the same. For squeeze, the new dimensions are simply the old dimensions with all singleton (==1) dimensions removed (except 2D inputs are left as is).
As for what it is used for, it may be that the result of some algorithm has left you with a 1x2x1x3 matrix and you need to feed that to a function that needs a 2D input. So you could use squeeze on it to get the 2D input as a 2x3 matrix.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!