what does squezee do in matlab

The squeeze function in MATLAB removes dimensions of length 1 from an array.

Syntax:

main.m
B = squeeze(A)
15 chars
2 lines

Example:

main.m
A = rand(2,1,3,1);
B = squeeze(A);
size(B)
43 chars
4 lines

Output:

main.m
ans =
     2 3
15 chars
3 lines

In the above example, A is a 4D array with dimensions of size 2, 1, 3, 1. The squeeze function removes dimensions of length 1, so the resulting array B is a 2D array with dimensions of size 2 and 3.

related categories

gistlibby LogSnag