time | Calls | line |
---|
| | 1 | function mustBeNonnegative(A)
|
| | 2 | %MUSTBENONNEGATIVE Validate that value is nonnegative
|
| | 3 | % MUSTBENONNEGATIVE(A) throws an error if A contains negaitive values.
|
| | 4 | % A value is nonnegative if it is greater than or equal to zero.
|
| | 5 | %
|
| | 6 | % Class support:
|
| | 7 | % All numeric classes, logical
|
| | 8 | % MATLAB classes that define these methods:
|
| | 9 | % ge, isreal, isnumeric, islogical
|
| | 10 | %
|
| | 11 | % See also: MUSTBENUMERICORLOGICAL, MUSTBEREAL.
|
| | 12 |
|
| | 13 | % Copyright 2016-2020 The MathWorks, Inc.
|
| | 14 |
|
< 0.001 | 2 | 15 | if ~isnumeric(A) && ~islogical(A)
|
| | 16 | throwAsCaller(createValidatorException('MATLAB:validators:mustBeNumericOrLogical'));
|
< 0.001 | 2 | 17 | end
|
| | 18 |
|
< 0.001 | 2 | 19 | if ~isreal(A)
|
| | 20 | throwAsCaller(createValidatorException('MATLAB:validators:mustBeReal'));
|
< 0.001 | 2 | 21 | end
|
| | 22 |
|
< 0.001 | 2 | 23 | if ~all(A >= 0, 'all')
|
| | 24 | throwAsCaller(createValidatorException('MATLAB:validators:mustBeNonnegative'));
|
< 0.001 | 2 | 25 | end
|
< 0.001 | 2 | 26 | end
|
Other subfunctions in this file are not included in this listing.