time | Calls | line |
---|
| | 1 | function varData = getVarOrRowLabelData(t,varIndices,wmsgid)
|
| | 2 | % Return the specified data vars and/or the row labels, wrapped up in a cell
|
| | 3 | % array. A var index of 0 indicates row labels. This is useful for collecting up
|
| | 4 | % sorting/grouping vars in methods like sortrows or varfun, but is not needed
|
| | 5 | % where only data vars are legal, e.g. InputVariables in varfun.
|
| | 6 |
|
| | 7 | % Copyright 2016-2017 The MathWorks, Inc.
|
| | 8 |
|
< 0.001 | 3 | 9 | isRowLabels = (varIndices == 0);
|
< 0.001 | 3 | 10 | if any(isRowLabels)
|
| | 11 | if t.rowDim.hasLabels
|
| | 12 | rowLabels = t.rowDim.labels;
|
| | 13 | else
|
| | 14 | % If there _are_ no row labels, warn and use the row indices.
|
| | 15 | % Timetable row times are required, this can only happen for
|
| | 16 | % tables. Error if a caller ends up here, has no row labels, and
|
| | 17 | % has not provided a warning id.
|
| | 18 | warning(message(wmsgid));
|
| | 19 | rowLabels = (1:t.rowDim.length)';
|
| | 20 | end
|
| | 21 | if isscalar(varIndices)
|
| | 22 | % If it's only the row labels, return quickly.
|
| | 23 | varData = { rowLabels };
|
| | 24 | return
|
| | 25 | end
|
| | 26 |
|
| | 27 | varData = cell(1,length(varIndices));
|
| | 28 | varData(isRowLabels) = { rowLabels };
|
| | 29 | isDataVar = ~isRowLabels;
|
| | 30 | varData(isDataVar) = t.data(varIndices(isDataVar));
|
< 0.001 | 3 | 31 | else
|
< 0.001 | 3 | 32 | varData = t.data(varIndices);
|
< 0.001 | 3 | 33 | end
|
Other subfunctions in this file are not included in this listing.