seconds - Duration in seconds - MATLAB (original) (raw)
Main Content
Syntax
Description
S = seconds([X](#buf%5Fvz%5F-1-X))
returns an array of seconds equivalent to the values in X
.
- If
X
is a numeric array, thenS
is aduration
array in units of seconds. - If
X
is aduration
array, thenS
is adouble
array with each element equal to the number of seconds in the corresponding element ofX
.
The seconds
function converts between duration
and double
values. To display a duration in units of seconds, set its Format
property to 's'
.
Examples
X = magic(4); S = seconds(X)
S = 4×4 duration 16 sec 2 sec 3 sec 13 sec 5 sec 11 sec 10 sec 8 sec 9 sec 7 sec 6 sec 12 sec 4 sec 14 sec 15 sec 1 sec
Create a duration
array.
X = hours(1) + minutes(1:4)
X = 1×4 duration 1.0167 hr 1.0333 hr 1.05 hr 1.0667 hr
Convert each duration in X
to a number of seconds.
S = 1×4
3660 3720 3780 3840
S
is a double
array.
Find the natural logarithm of S
. The log
function accepts inputs of type double
.
Y = 1×4
8.2052 8.2215 8.2375 8.2532
Input Arguments
Input array, specified as a numeric array, duration array, or logical array.
Extended Capabilities
Theseconds
function fully supports tall arrays. For more information, see Tall Arrays.
Version History
Introduced in R2014b