seconds
Creates durations in seconds, or converts durations to a number of seconds.
Category: Language Fundamentals > Data Types
Syntax
d = seconds(x)
Returns a duration of x seconds.
x = seconds(d)
Given a duration d, returns its length in seconds as a double.
Description
seconds is one of a family (milliseconds, minutes, hours, days, years) that work in both directions. Passing a number builds a duration; passing a duration returns a plain number in that unit. Durations can be added to datetimes, and seconds(1:4) is a convenient time vector for a timetable.
Input arguments
x- Numeric array.
d- Duration array.
Output arguments
d- Duration array with the same size as
x. x- Double array.
Example
seconds(90)
seconds([1 2])
seconds(minutes(2))
Output
ans = duration
90 sec
ans = 1×2 duration array
1 sec 2 sec
ans = 120