23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2 Data Types<br />

Date Strings<br />

There are a number of different styles in which to express date and time<br />

information as a date string. For example, several possibilities for October 31,<br />

2003 at 3:45:17 in the afternoon are<br />

31-Oct-2003 15:45:17<br />

10/31/03<br />

15:45:17<br />

03:45:17 PM<br />

If you are working with a small number of dates at the <strong>MATLAB</strong> command<br />

line,thendatestringsareoftenthemostconvenientformattouse.<br />

Note The <strong>MATLAB</strong> date function returns the current date as a string.<br />

Serial Date Numbers<br />

A serial date number represents a calendar date as the number of days that<br />

has passed since a fixed base date. In <strong>MATLAB</strong>, serial date number 1 is<br />

January 1, 0000. <strong>MATLAB</strong> also uses serial timetorepresentfractionsofdays<br />

beginning at midnight; for example, 6 p.m. equals 0.75 serial days. So the<br />

string ’31-Oct-2003, 6:00 pm’ in <strong>MATLAB</strong> is date number 731885.75.<br />

<strong>MATLAB</strong> works internally with serial date numbers. If you are using<br />

functions that handle large numbers of dates or doing extensive calculations<br />

with dates, you get better performance if you use date numbers.<br />

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

serial date number.<br />

Date Vectors<br />

Date vectors are an internal format for some <strong>MATLAB</strong> functions; you do not<br />

typically use them in calculations. A date vector contains the elements [year<br />

month day hour minute second].<br />

2-68

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

Saved successfully!

Ooh no, something went wrong!