How does Squeeze work?
Mostrar comentarios más antiguos
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 :-)
Respuesta aceptada
Más respuestas (1)
James Tursa
el 1 de Mayo de 2011
3 votos
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.
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!