You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
INRANGE tests if values are within a specified range (interval).
INRANGE(X,RANGE) tests if the values in X are within the range specified by RANGE. X can be a vector or matrix.
RANGE is a range in the form [LOW HIGH] against which each value in X will be tested. RANGE can also be a two-column vector whose ith row is of form RANGE(i,:) = [LOW HIGH]. In this form, input X must be a vector with the same length as RANGE, and each element of X is tested against the range in the corresponding row of RANGE.
INRANGE(X,RANGE,BOUNDARY) specifies whether the endpoints of the specified range should be included or excluded from the interval. The options for BOUNDARY are:
'includeboth' : Both end points included in interval (default)
'includeleft' : Left end point only included in interval
'includeright': Right end point only included in interval
'excludeboth' : Neither end point included in interval
If the LOW and HIGH values for RANGE are equal, that single value will be found in range only under the 'includeboth' option (default). Otherwise, for this case, no values will be found in range.
Examples:
X = 1:10
X =
1 2 3 4 5 6 7 8 9 10
Y = inrange(X,[5 7.2],'includeboth')
Y =
0 0 0 0 1 1 1 0 0 0
Y = inrange(X,[5 7.2],'excludeboth')
Y =
0 0 0 0 0 1 1 0 0 0
See also ISVALID.
Cite As
David Fass (2026). INRANGE (https://se.mathworks.com/matlabcentral/fileexchange/12591-inrange), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.0.0 (3.39 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 | Made most of the fixes suggested by "Jos x" (thanks!). See M-file help.
|
