allbetween
R2026bSyntax
Description
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 tf = allbetween(___,DataVariables=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 a scalar, vector, matrix, multidimensional 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 a scalar, vector, matrix, multidimensional
array, table, or timetable. lower must be an object with the class
methods lt (<) or le (<=).
| Input Data Type | Bound Behavior | How to Specify lower |
|---|---|---|
| Array | Same lower bound for all elements of A | Scalar |
| Array | Different lower bound for each column of A | Row vector |
| Array | Different lower bound for each row of A | Column vector |
| Array | Same bound for all elements of A | Array of the same size as A |
| Table or timetable | Same lower bound for all elements of A | Scalar |
| Table or timetable | Different lower bound for each variable of A | One-row table or timetable with variables from A |
| Table or timetable | Different lower bound for each element of A | Table or timetable with the same variable names and number of rows as
A |
Upper bound of the range, specified as a scalar, vector, matrix, multidimensional
array, table, or timetable. upper must be an object with the class
methods lt (<) or le (<=).
| Input Data Type | Bound Behavior | How to Specify upper |
|---|---|---|
| Array | Same upper bound for all elements of A | Scalar |
| Array | Different upper bound for each column of A | Row vector |
| Array | Different upper bound for each row of A | Column vector |
| Array | Same upper for all elements of A | Array of the same size as A |
| Table or timetable | Same upper bound for all elements of A | Scalar |
| Table or timetable | Different upper bound for each variable of A | One-row table or timetable with variables from A |
| Table or timetable | Different upper bound for each element of A | Table or timetable with the same variable names and number of rows as
A |
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.
Output Arguments
Indicator that all values are within range, returned as a logical scalar.
tf is logical 1 (true) if all
elements in A are within the range defined by the lower and upper
bounds. Otherwise, tf is logical 0
(false).
Data Types: logical
Extended Capabilities
Usage notes and limitations:
Input data or bounds of type
datetimeordurationis not supported.
Refer to the usage notes and limitations in the C/C++ Code Generation section. The same usage notes and limitations apply to GPU code generation.
The
allbetween function fully supports GPU arrays.
To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more
information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
The
allbetween function fully supports distributed arrays. For more
information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced in R2025aGenerate C or C++ code for the allbetween function. For usage
notes and limitations, see C/C++ Code Generation.
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)
