d = duration(h, m, s)
d = duration(h, m, s, ms)
d = duration(text)
d = duration(text, 'InputFormat', fmt)
d = duration(x)
| Parameter | Description |
|---|---|
| inputs | Hours, minutes, seconds, optional milliseconds, duration text, or an N-by-3 numeric matrix. |
| Parameter | Description |
|---|---|
| output | A duration array storing elapsed seconds and a display format. |
Create elapsed time durations.
The constructor accepts numeric parts and common colon-separated text forms. Use hours, minutes, seconds, milliseconds, days, and years for unit-specific construction and conversion.
string returns the display text of each element and <missing> for a NaN duration; the display, char and cellstr keep the text NaN (cellstr(d, fmt) uses the format fmt). duration(missing), and assigning missing into a duration array, give NaN.
duration.empty(m, n, ...) returns an empty duration array. A comparison with missing is false (~= is true), as with a NaN duration.
Array-valued inputs keep their data shape when the operation supports arrays. Scalar operands are expanded where the implementation defines scalar expansion.
d = duration(1, 2, 3)
seconds(d)
duration('1:02', 'InputFormat', 'mm:ss')
string(seconds([1 NaN]))
| Version | Description |
|---|---|
| 2.0.0 | initial version |