time | Calls | line |
---|
| | 36 | function obj = metaDim(length,labels,backwardsCompatibility)
|
| | 37 | % Technically, this is not a table dimension, it's more like a table
|
| | 38 | % meta-dimension. But it's close enough to var and row names to
|
| | 39 | % reuse the infrastructure. Always initialize with two default
|
| | 40 | % names, and oriented as a row.
|
| | 41 | import matlab.internal.datatypes.isCharStrings
|
| | 42 | import matlab.internal.tabular.private.metaDim
|
| | 43 |
|
< 0.001 | 2 | 44 | if nargin == 0
|
< 0.001 | 2 | 45 | length = 2;
|
< 0.001 | 2 | 46 | labels = metaDim.dfltLabels;
|
| | 47 | elseif nargin == 1
|
| | 48 | labels = metaDim.dfltLabels;
|
| | 49 | else
|
| | 50 | % This is the relevant parts of validateAndAssignLabels
|
| | 51 | if ~(isCharStrings(labels,true) && all(strlength(labels) > 0, 'all')) % require cellstr, whitespace, but not empty allowed
|
| | 52 | error(message('MATLAB:table:InvalidDimNames'));
|
| | 53 | end
|
| | 54 | labels = strtrim(labels(:)'); % a row vector, conveniently forces any empty to 0x1
|
| | 55 | if (nargin > 2) && backwardsCompatibility % tables, for now
|
| | 56 | labels = obj.fixLabelsForCompatibility(labels);
|
| | 57 | else % timetables
|
| | 58 | metaDim.makeValidName(labels,'error');
|
| | 59 | obj.checkDuplicateLabels(labels);
|
| | 60 | end
|
< 0.001 | 2 | 61 | end
|
| | 62 |
|
< 0.001 | 2 | 63 | if nargin < 3 || (nargin==3 && ~backwardsCompatibility)
|
0.001 | 2 | 64 | obj = obj.init(length,labels);
|
| | 65 | else
|
| | 66 | obj = obj.initWithCompatibility(length,labels);
|
< 0.001 | 2 | 67 | end
|
< 0.001 | 2 | 68 | end
|
Other subfunctions in this file are not included in this listing.