seconds

Duration in seconds

Description

example

S = seconds(X) returns an array of seconds equivalent to the values in X.

  • If X is a numeric array, then S is a duration array in units of seconds.

  • If X is a duration array, then S is a double array with each element equal to the number of seconds in the corresponding element of X.

The seconds function converts between duration and double values. To display a duration in units of seconds, set its Format property to 's'.

Examples

collapse all

X =  magic(4);
S = seconds(X)
S = 4x4 duration array
   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 = 1x4 duration array
   1.0167 hr   1.0333 hr     1.05 hr   1.0667 hr

Convert each duration in X to a number of seconds.

S = seconds(X)
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 = log(S)
Y = 1×4

    8.2052    8.2215    8.2375    8.2532

Input Arguments

collapse all

Input array, specified as a numeric array, duration array, or logical array.

Extended Capabilities

See Also

Introduced in R2014b