isduration
Tests whether a value is a duration array.
Category: Language Fundamentals > Data Types
Syntax
tf = isduration(A)
Returns true if A is a duration array, false otherwise.
Description
The test looks only at the class. Arrays built by seconds, minutes, hours, days or by subtracting two datetimes are durations. A plain number such as 3, even when it represents a time span, is not.
Input arguments
A- Any value.
Output arguments
tf- Logical scalar.
Example
Durations versus numbers
isduration(hours(2))
isduration(datetime(2024,1,2) - datetime(2024,1,1))
isduration(2)
Output
ans = logical
1
ans = logical
1
ans = logical
0