time | Calls | line |
---|
| | 1 | function that = subsref(this,s)
|
| | 2 | %SUBSREF Subscripted reference for a categorical array.
|
| | 3 | % B = SUBSREF(A,S) is called for the syntax A(I). S is a structure array
|
| | 4 | % with the fields:
|
| | 5 | % type -- Character vector containing '()' specifying the subscript type.
|
| | 6 | % Only parenthesis subscripting is allowed.
|
| | 7 | % subs -- Cell array containing the actual subscripts.
|
| | 8 | %
|
| | 9 | % See also CATEGORICAL/CATEGORICAL, SUBSASGN.
|
| | 10 |
|
| | 11 | % Copyright 2006-2016 The MathWorks, Inc.
|
| | 12 |
|
| | 13 | import matlab.internal.datatypes.tryThrowIllegalDotMethodError
|
| | 14 |
|
| | 15 | % Make sure nothing follows the () subscript.
|
0.033 | 618310 | 16 | if ~isscalar(s)
|
| | 17 | isDotParenReference = isequal({s.type},{'.','()'});
|
| | 18 | if isDotParenReference
|
| | 19 | name = s.subs;
|
| | 20 | tryThrowIllegalDotMethodError(this,name,'MethodsWithNoCorrection',"cat");
|
| | 21 | error(message('MATLAB:categorical:FieldReferenceNotAllowed'));
|
| | 22 | else
|
| | 23 | error(message('MATLAB:categorical:InvalidSubscripting'));
|
| | 24 | end
|
0.028 | 618310 | 25 | end
|
| | 26 |
|
0.079 | 618310 | 27 | switch s.type
|
0.093 | 618310 | 28 | case '()'
|
| | 29 | % Normally, only multi-level paren references like c(i).Property get here,
|
| | 30 | % and for categorical those are an error and caught above. Simple paren
|
| | 31 | % references should normally go to parenReference. But someone (including
|
| | 32 | % tabular) might call this method explicitly, so handle the latter.
|
6.384 | 618310 | 33 | that = this.parenReference(s.subs{:});
|
| | 34 | case '{}'
|
| | 35 | error(message('MATLAB:categorical:CellReferenceNotAllowed'))
|
| | 36 | case '.'
|
| | 37 | name = s.subs;
|
| | 38 | tryThrowIllegalDotMethodError(this,name,'MethodsWithNoCorrection',"cat");
|
| | 39 | error(message('MATLAB:categorical:FieldReferenceNotAllowed'));
|
0.071 | 618310 | 40 | end
|