0
votes

I'm trying to import some data in Matlab from a text file (.text extension). This data contain the next information: date and traffic from different detectors at specific times (each 15 min). Something like:

Friday, 10 March 2012
      Method         sensor(s)...
      Approach  1    1    2    3    4    5    6    7    8    9   10 
00:15 Approach  1   10   16   14    7    7   63   68   17    0    0
00:30 Approach  1    7   15    9    4    4   55   50   21    0    0
00:45 Approach  1    7   14    7    7    3   37   41   11    0    0
01:00 Approach  1    6   14    9    5    4   50   46    8    0    0
.
.
.
24:00 Approach  1   14   48   50   10    2  107  104   27    0    0
Approach  1 AM peak    1918 08:00 - 09:00   
Saturday, 11 March 2012
      Method         sensor(s)...
      Approach  1    1    2    3    4    5    6    7    8    9   10 
00:15 Approach  1   10   16   14    7    7   63   68   17    0    0
00:30 Approach  1    7   15    9    4    4   55   50   21    0    0
00:45 Approach  1    7   14    7    7    3   37   41   11    0    0
01:00 Approach  1    6   14    9    5    4   50   46    8    0    0
.
.
.

I am trying to use the import tool in Matlab, but when I am trying to import the file it assigns one type of data to each column. Because of the position of the date in the document, I am losing this information (is set as NaN), which is vital. Is there a way to import this data without losing the date?

1

1 Answers

0
votes

You can fgets to get the first line of the input file and the code generated by the import module to get the data from the rest of the file. For example, assuming your input file is named test.txt:

fid = fopen('test.txt')
date = fgets(fid)