MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
t =

1×4 datetime array

18-Jul-2014 18-Aug-2014 18-Sep-2014 18-Oct-2014

Subtract the origin value. For example, the origin value might be the starting day of an
experiment.

dt = t - datetime(2014,7,1)

dt =

1×4 duration array

408:00:00 1152:00:00 1896:00:00 2616:00:00

dt is a duration array. Convert dt to a double array of values in units of years, days,
hours, minutes, or seconds using the years, days, hours, minutes, or seconds
function, respectively.

x = hours(dt)

x =

408 1152 1896 2616

Pass the double array as the input to the log function.

y = log(x)

y =

6.0113 7.0493 7.5475 7.8694

See Also
cellstr | char | datenum | datetime | datevec

More About



  • “Represent Dates and Times in MATLAB” on page 7-2


7 Dates and Time

Free download pdf