B = squeeze(A) returns an array B with the same elements as A, but with all singleton dimensions removed. A singleton dimension is any dimension for which size(A,dim) = 1.
Also check this : https://www.mathworks.com/matlabcentral/answers/6560-how-does-squeeze-work