time | Calls | line |
---|
| | 1 | function [tf,isInt] = isScalarInt(x,lower,upper) %#codegen
|
| | 2 | %ISSCALARINT Require a scalar integer
|
| | 3 | % T = ISSCALARINT(X) returns true if X is a scalar integer value, and false
|
| | 4 | % otherwise.
|
| | 5 | %
|
| | 6 | % T = ISSCALARINT(X,0) returns true if X is a non-negative scalar integer
|
| | 7 | % value, and false otherwise.
|
| | 8 | %
|
| | 9 | % T = ISSCALARINT(X,1) returns true if X is a positive scalar integer value,
|
| | 10 | % and false otherwise.
|
| | 11 | %
|
| | 12 | % T = ISSCALARINT(X,LOWER,UPPER) returns true if X is a scalar integer value
|
| | 13 | % from LOWER to UPPER, and false otherwise.
|
| | 14 | %
|
| | 15 | % [T,ISINT] = ISSCALARINT(X,...) returns true in ISINT if X is a scalar
|
| | 16 | % integer value, even if it is not within the desired range.
|
| | 17 |
|
| | 18 | % Copyright 2013 The MathWorks, Inc.
|
| | 19 |
|
0.056 | 1026418 | 20 | if isscalar(x)
|
0.064 | 1026418 | 21 | isInt = isnumeric(x) && isreal(x) && (round(x) == x) && isfinite(x);
|
0.053 | 1026418 | 22 | if nargin == 1
|
| | 23 | tf = isInt;
|
0.050 | 1026418 | 24 | elseif nargin == 2
|
0.051 | 1026410 | 25 | tf = isInt && (x >= lower);
|
< 0.001 | 8 | 26 | else % nargin == 3
|
< 0.001 | 8 | 27 | tf = isInt && (lower <= x) && (x <= upper);
|
0.048 | 1026418 | 28 | end
|
| | 29 | else
|
| | 30 | tf = false;
|
| | 31 | isInt = false;
|
0.146 | 1026418 | 32 | end
|
Other subfunctions in this file are not included in this listing.