Difference between revisions of "LoadingData"
(→Dealing with date vectors) |
|||
Line 17: | Line 17: | ||
When dealing with time series data you will often want to keep date information. MATLAB has excellent date functionality and dealing with data is indeed one of its strengths. There are two principle formats in which MATLAB handles dates, the <source enclose=none>datenum</source> and the <source enclose=none>datevec</source> format | When dealing with time series data you will often want to keep date information. MATLAB has excellent date functionality and dealing with data is indeed one of its strengths. There are two principle formats in which MATLAB handles dates, the <source enclose=none>datenum</source> and the <source enclose=none>datevec</source> format | ||
− | # The <source enclose=none>datenum</source> format: Here MATLAB records date information in terms of the number of days since 01 Jan 0000. This day is given the number 1. The next day (2 Jan 0000) is assigned number 2 and so forth. The 22 Sept 2012 is 735134. | + | # The <source enclose=none>datenum</source> format: Here MATLAB records date information in terms of the number of days since 01 Jan 0000. This day is given the number 1. The next day (2 Jan 0000) is assigned the number 2 and so forth. The 22 Sept 2012 is 735134. |
# The <source enclose=none>datevec</source> format: Here a date is transformed into a (1 x 6) vector where the first element represents the year, the second the month, the third the day, the fourth the hour, the fith the minutes and the sixth the seconds. If you only enter a day, the last three entries will take the value 0. | # The <source enclose=none>datevec</source> format: Here a date is transformed into a (1 x 6) vector where the first element represents the year, the second the month, the third the day, the fourth the hour, the fith the minutes and the sixth the seconds. If you only enter a day, the last three entries will take the value 0. | ||
+ | |||
+ | It is a great feature of MATLAB that it recognises a good number of different ways to enter data |
Revision as of 19:46, 22 September 2012
Data Sources
Usually you will have data saved in some file, like Excel files, csv (comma seperated values) file or a text file. These are the most common formats in which you can download data from various databases.
By far the easiest formats to import data into MATLAB are Excel spreadsheets and csv files.
The most common
double click on
if text data then use command line:
[NUM,TXT,RAW]=xlsread(FILE,SHEET) as that will save the textdata in TXT and RAW
Dealing with date vectors
When dealing with time series data you will often want to keep date information. MATLAB has excellent date functionality and dealing with data is indeed one of its strengths. There are two principle formats in which MATLAB handles dates, the datenum
and the datevec
format
- The
datenum
format: Here MATLAB records date information in terms of the number of days since 01 Jan 0000. This day is given the number 1. The next day (2 Jan 0000) is assigned the number 2 and so forth. The 22 Sept 2012 is 735134.
- The
datevec
format: Here a date is transformed into a (1 x 6) vector where the first element represents the year, the second the month, the third the day, the fourth the hour, the fith the minutes and the sixth the seconds. If you only enter a day, the last three entries will take the value 0.
It is a great feature of MATLAB that it recognises a good number of different ways to enter data