time | Calls | line |
---|
| | 1 | function b = squeeze(a)
|
| | 2 | %SQUEEZE Remove singleton dimensions.
|
| | 3 | % B = SQUEEZE(A) returns an array B with the same elements as
|
| | 4 | % A but with all the singleton dimensions removed. A singleton
|
| | 5 | % is a dimension such that size(A,dim)==1. 2-D arrays are
|
| | 6 | % unaffected by squeeze so that row vectors remain rows.
|
| | 7 | %
|
| | 8 | % For example,
|
| | 9 | % squeeze(rand(2,1,3))
|
| | 10 | % is 2-by-3.
|
| | 11 | %
|
| | 12 | % See also SHIFTDIM.
|
| | 13 |
|
| | 14 | % Copyright 1984-2010 The MathWorks, Inc.
|
| | 15 |
|
< 0.001 | 2555 | 16 | if nargin==0
|
| | 17 | error(message('MATLAB:squeeze:NotEnoughInputs'));
|
< 0.001 | 2555 | 18 | end
|
| | 19 |
|
< 0.001 | 2555 | 20 | if ~ismatrix(a)
|
0.003 | 2555 | 21 | siz = size(a);
|
0.011 | 2555 | 22 | siz(siz==1) = []; % Remove singleton dimensions.
|
0.017 | 2555 | 23 | siz = [siz ones(1,2-length(siz))]; % Make sure siz is at least 2-D
|
0.004 | 2555 | 24 | b = reshape(a,siz);
|
| | 25 | else
|
| | 26 | b = a;
|
0.002 | 2555 | 27 | end
|
Other subfunctions in this file are not included in this listing.