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.

2 Data Types<br />

• The day field is an integer from 1 to 31.<br />

• The month field is either an integer from 1 to 12 or an alphabetic string<br />

with at least three characters.<br />

• The year field is a nonnegative integer: if only two digits are specified,<br />

then a year 19yy is assumed; if the year is omitted, then the current year<br />

is used as a default.<br />

• The hours, minutes, and seconds fields are optional. They are integers<br />

separated by colons or followed by 'AM' or 'PM'.<br />

For example, if the current year is 1996, then these are all equivalent:<br />

'17-May-1996'<br />

'17-May-96'<br />

'17-May'<br />

'May 17, 1996'<br />

'5/17/96'<br />

'5/17'<br />

and both of these represent the same time:<br />

'17-May-1996, 18:30'<br />

'5/17/96/6:30 pm'<br />

Note that the default format for numbers-only input follows the American<br />

convention. Thus 3/6 is March 6, not June 3.<br />

If you create a vector of input date strings, use a column vector and be sure all<br />

strings are the same length. Fill in with spaces or zeros.<br />

Output Formats<br />

The command datestr(D, dateform) converts a serial date D to one of 19<br />

different date string output formats showing date, time, or both. The default<br />

output for dates is a day-month-year string: 01-Mar-1996. You select an<br />

alternative output format by using the optional integer argument dateform.<br />

This table shows the date string formats that correspond to each dateform<br />

value.<br />

2-70

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

Saved successfully!

Ooh no, something went wrong!