Documentation

seconds

Duration in seconds

Syntax

S = seconds(X)

Description

example

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

  • IfXis a numeric array, thenSis adurationarray in units of seconds.

  • IfXis adurationarray, thenSis adoublearray with each element equal to the number of seconds in the corresponding element ofX.

Thesecondsfunction converts betweendurationanddoublevalues. To display a duration in units of seconds, set itsFormatproperty to's'.

Examples

collapse all

X = magic(4); S = seconds(X)
S =4x4 duration array16 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 adurationarray.

X = hours(1) + minutes(1:4)
X =1x4 duration array1.0167 hr 1.0333 hr 1.05 hr 1.0667 hr

Convert each duration inXto a number of seconds.

S = seconds(X)
S =3660 3720 3780 3840

Sis adoublearray.

Find the natural logarithm ofS. Thelogfunction accepts inputs of typedouble.

Y = log(S)
Y =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

Was this topic helpful?