time | Calls | line |
---|
| | 1 | function tf = isScalarText(txt,allowEmptyOrMissing)
|
| | 2 | %ISSCALARTEXT True for a scalar text value
|
| | 3 | % TF = ISSCALARTEXT(TXT) returns true if TXT is a scalar text value, i.e.
|
| | 4 | % * a scalar string
|
| | 5 | % * a 1xN character vector
|
| | 6 | % * the 0x0 char array ''
|
| | 7 | %
|
| | 8 | % TF = ISSCALARTEXT(TXT,FALSE) returns true only if TXT is a non-empty,
|
| | 9 | % non-missing text value, i.e.
|
| | 10 | % * a scalar string not equal to "", all whitespace, or <missing>
|
| | 11 | % * a 1xN character vector for N > 0, not all whitespace
|
| | 12 | %
|
| | 13 | % Note that ISSCALARTEXT returns FALSE for a scalar cellstr.
|
| | 14 | %
|
| | 15 | % See also MATLAB.INTERNAL.DATATYPES.ISTEXT, ISSPACE, STRINGS.
|
| | 16 |
|
| | 17 | % Copyright 2017 The MathWorks, Inc.
|
| | 18 |
|
< 0.001 | 8 | 19 | if nargin < 2 || allowEmptyOrMissing % allow empty or missing
|
< 0.001 | 8 | 20 | if ischar(txt)
|
< 0.001 | 8 | 21 | tf = (isrow(txt) || isequal(txt,'')); % empty and missing same for char
|
| | 22 | elseif isstring(txt)
|
| | 23 | tf = isscalar(txt);
|
| | 24 | else
|
| | 25 | tf = false;
|
< 0.001 | 8 | 26 | end
|
| | 27 | else % do not allow empty or missing
|
| | 28 | if ischar(txt)
|
| | 29 | tf = isrow(txt) && ~all(isspace(txt)); % ~all(isspace(txt)) catches 1x0
|
| | 30 | elseif isstring(txt)
|
| | 31 | tf = isscalar(txt) && ~ismissing(txt) && ~all(isspace(txt));
|
| | 32 | else
|
| | 33 | tf = false;
|
| | 34 | end
|
< 0.001 | 8 | 35 | end
|
Other subfunctions in this file are not included in this listing.