time | Calls | line |
---|
| | 1 | function varargout = size(t,dim,varargin)
|
| | 2 | %SIZE Size of a table.
|
| | 3 | % D = SIZE(T) returns the two-element row vector D = [NROWS,NVARS] containing
|
| | 4 | % the number of rows and variables in the table T.
|
| | 5 | %
|
| | 6 | % [NROWS,NVARS] = SIZE(T) returns the number of rows and variables in the
|
| | 7 | % table T as separate output variables.
|
| | 8 | %
|
| | 9 | % [M1,M2,M3,...,MN] = SIZE(T), for N>1, returns the sizes of the first N
|
| | 10 | % dimensions of the table T. If the number of output arguments N does not
|
| | 11 | % equal NDIMS(T), then for:
|
| | 12 | %
|
| | 13 | % N > NDIMS(T), SIZE returns ones in the "extra" variables, i.e., outputs
|
| | 14 | % NDIMS(T)+1 through N.
|
| | 15 | % N < NDIMS(T), MN contains the product of the sizes of dimensions N
|
| | 16 | % through NDIMS(T).
|
| | 17 | %
|
| | 18 | % M = SIZE(T,DIM) returns the lengths of the specified dimensions in a
|
| | 19 | % row vector. DIM can be a scalar or vector of dimensions. For example,
|
| | 20 | % SIZE(T,1) returns the number of rows of T, and SIZE(T,[1 2]) returns a
|
| | 21 | % row vector containing the number of rows and variables.
|
| | 22 | %
|
| | 23 | % M = SIZE(X,DIM1,DIM2,...,DIMN) returns the lengths of the dimensions
|
| | 24 | % DIM1,...,DIMN as a row vector.
|
| | 25 | %
|
| | 26 | % [M1,M2,...,MN] = SIZE(X,DIM) OR [M1,M2,...,MN] = SIZE(X,DIM1,...,DIMN)
|
| | 27 | % returns the lengths of the specified dimensions as separate outputs.
|
| | 28 | % The number of outputs must equal the number of dimensions provided.
|
| | 29 | %
|
| | 30 | % See also HEIGHT, WIDTH, NUMEL, NDIMS.
|
| | 31 |
|
| | 32 | % Copyright 2012-2019 The MathWorks, Inc.
|
| | 33 |
|
| | 34 | import matlab.internal.datatypes.isIntegerVals
|
| | 35 | import matlab.internal.datatypes.isScalarInt
|
| | 36 |
|
< 0.001 | 3937 | 37 | if nargin == 1
|
< 0.001 | 3929 | 38 | if nargout < 2
|
0.005 | 2359 | 39 | varargout = {[t.rowDim.length t.varDim.length]};
|
< 0.001 | 1570 | 40 | elseif nargout == 2
|
0.003 | 1570 | 41 | varargout = {t.rowDim.length t.varDim.length};
|
| | 42 | else
|
| | 43 | varargout(1:2) = {t.rowDim.length t.varDim.length};
|
| | 44 | varargout(3:nargout) = {1};
|
< 0.001 | 3929 | 45 | end
|
< 0.001 | 8 | 46 | elseif nargin == 2
|
< 0.001 | 8 | 47 | if isScalarInt(dim,1,2^48)
|
< 0.001 | 8 | 48 | nargoutchk(0,1);
|
< 0.001 | 8 | 49 | if dim == 1
|
| | 50 | varargout = {t.rowDim.length};
|
< 0.001 | 8 | 51 | elseif dim == 2
|
< 0.001 | 8 | 52 | varargout = {t.varDim.length};
|
| | 53 | else
|
| | 54 | varargout = {1};
|
< 0.001 | 8 | 55 | end
|
| | 56 | elseif isIntegerVals(dim,1,2^48) && ~isempty(dim)
|
| | 57 | out = ones(size(dim));
|
| | 58 | out(dim==1) = t.rowDim.length;
|
| | 59 | out(dim==2) = t.varDim.length;
|
| | 60 | if nargout < 2
|
| | 61 | varargout = {out};
|
| | 62 | else
|
| | 63 | varargout(1:nargout) = num2cell(out);
|
| | 64 | end
|
| | 65 | else
|
| | 66 | error(message('MATLAB:table:size:InvalidDim'));
|
< 0.001 | 8 | 67 | end
|
| | 68 | else % varargin
|
| | 69 | dim = [dim, varargin{:}];
|
| | 70 | isDimsArg = ~isempty(dim) && isIntegerVals(dim,1,2^48) ...
|
| | 71 | && (length(dim) == nargin-1);
|
| | 72 | if ~isDimsArg
|
| | 73 | error(message('MATLAB:table:size:InvalidDim'));
|
| | 74 | end
|
| | 75 | out = ones(size(dim));
|
| | 76 | out(dim==1) = t.rowDim.length;
|
| | 77 | out(dim==2) = t.varDim.length;
|
| | 78 | nargoutchk(0,numel(dim));
|
| | 79 | if nargout < 2
|
| | 80 | varargout = {out};
|
| | 81 | else
|
| | 82 | varargout(1:nargout) = num2cell(out);
|
| | 83 | end
|
| | 84 |
|
< 0.001 | 3937 | 85 | end
|
0.002 | 3937 | 86 | end
|
Other subfunctions in this file are not included in this listing.