allbetween
Syntax
Description
tf = allbetween(
specifies the type of interval. For example,
A,lower,upper,intervalType)allbetween(A,lower,upper,"open") determines if elements in
A are within the open interval (lower,upper).
tf = allbetween(___,DataVariables=
specifies the table or timetable variables to operate on in addition to any of the input
argument combinations in previous syntaxes. For example, for table vars)A,
allbetween(A,lower,upper,DataVariables="Var1") determines if elements
in table variable Var1 are within the specified range.
Examples
Create a row vector, and determine if all elements in the vector are within [2, 7].
A = [1 3 5 7 9]; tf = allbetween(A,2,7)
tf = logical
0
To determine which elements are outside the specified range, use the isbetween function.
Create a row vector, and determine if all elements in the vector are within (1, 10). Specify the interval type as "open" to exclude the lower and upper bounds.
A = 1:7;
tf = allbetween(A,1,10,"open")tf = logical
0
The result is logical 0 (false) because the first element in the vector is equal to the lower bound. Include the lower bound in the allowed range by specifying the interval type as "closedleft".
tf2 = allbetween(A,1,10,"closedleft")tf2 = logical
1
Create a table with two variables of different data types.
num = rand(6,1); dt = datetime(2016:2021,1,1)'; T = table(num,dt)
T=6×2 table
num dt
_______ ___________
0.81472 01-Jan-2016
0.90579 01-Jan-2017
0.12699 01-Jan-2018
0.91338 01-Jan-2019
0.63236 01-Jan-2020
0.09754 01-Jan-2021
Specify the bounds for variables of different data types in one-row tables.
lower = table(0,datetime(2018,1,1),VariableNames=["num" "dt"])
lower=1×2 table
num dt
___ ___________
0 01-Jan-2018
upper = table(Inf,datetime(2020,1,1),VariableNames=["num" "dt"])
upper=1×2 table
num dt
___ ___________
Inf 01-Jan-2020
Determine if all elements in the num variable are within the specified range.
tf = allbetween(T,lower,upper,DataVariables="num")tf = logical
1
Determine if all elements in both variables are within the specified ranges.
tf2 = allbetween(T,lower,upper)
tf2 = logical
0
Input Arguments
Input data, specified as an array, table, or timetable.
A must be an object with the class methods lt
(<) or le (<=).
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | categorical | datetime | duration | table | timetable
Lower bound of the range, specified as an array or one-row table. The lower and
upper bounds must either be the same size or have sizes that are compatible. lower must be an object with the class methods
lt (<) or le (<=).
To use the same lower bound for all elements of
A, specifyloweras a scalar.To use different lower bounds for each column or row in
A, specifyloweras a row or column vector, respectively.To use a different lower bound for each data element, specify
loweras an array of the same size asA.
For tabular input data, when the table variables to operate on have different data types, specify the lower bound as a one-row table. The variable names of the one-row table must be the same as the names of the table variables to operate on.
Upper bound of the range, specified as an array or one-row table. The lower and
upper bounds must either be the same size or have sizes that are compatible. upper must be an object with the class methods
lt (<) or le (<=).
To use the same upper bound for all elements of
A, specifyupperas a scalar.To use different upper bounds for each column or row in
A, specifyupperas a row or column vector, respectively.To use a different upper bound for each data element, specify
upperas an array of the same size asA.
For tabular input data, when the table variables to operate on have different data types, specify the upper bound as a one-row table. The variable names of the one-row table must be the same as the names of the table variables to operate on.
Type of interval that defines the range of allowed values, specified as one of the values in this table.
Type of Interval | Diagram | Description |
|---|---|---|
|
| Include |
|
| Exclude |
|
| Exclude
|
|
| Include
|
Table or timetable variables to operate on, specified as one of the values in this table.
allbetween operates only on elements in the specified
variables in A.
| Indexing Scheme | Values to Specify | Examples |
|---|---|---|
Variable name |
|
|
Variable index |
|
|
Function handle |
|
|
Variable type |
|
|
Example: tf = allbetween(T,lower,upper,DataVariables=["Var1" "Var2"
"Var4"]) determines if the elements in the Var1,
Var2, and Var4 variables in table
T are within the specified range.
Version History
Introduced in R2025a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
![Closed interval [lower, upper]](interval-notation-02.png)

![Half-open interval (lower, upper]](interval-notation-04.png)
