23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dates and Times<br />

Note The <strong>MATLAB</strong> clock function returns the current date and time as a<br />

serial vector.<br />

Conversions Between Date Formats<br />

Functions that convert between date formats are shown below.<br />

Function<br />

datenum<br />

datestr<br />

datevec<br />

Description<br />

Convert a date string to a serial date number.<br />

Convert a serial date number to a date string.<br />

Split a date number or date string into individual<br />

date elements.<br />

Herearesomeexamplesofconversionsfromonedateformattoanother:<br />

d1 = datenum('02-Oct-1996')<br />

d1 =<br />

729300<br />

d2 = datestr(d1 + 10)<br />

d2 =<br />

12-Oct-1996<br />

dv1 = datevec(d1)<br />

dv1 =<br />

1996 10 2 0 0 0<br />

dv2 = datevec(d2)<br />

dv2 =<br />

1996 10 12 0 0 0<br />

Date String Formats<br />

The datenum function is important for doing date calculations efficiently.<br />

datenum takes an input string in any of several formats, with 'dd-mmm-yyyy',<br />

'mm/dd/yyyy', or'dd-mmm-yyyy, hh:mm:ss.ss' most common. You can<br />

form up to six fields from letters and digits separated by any other characters:<br />

2-69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!