Command to import data from file

2.5k Views Asked by At

I'm using MATLAB to organize IR camera measurement data and I'd like to work more efficient than now.

The SW for IR camera exports data organised in columns

Some text
488.875 1300110589.875  2   14.3.2011 14:49:49.875  0   1
488.875 1300110590.156  2   14.3.2011 14:49:50.156  0   2
488.875 1300110590.671  2   14.3.2011 14:49:50.671  0   3
488.875 1300110590.953  2   14.3.2011 14:49:50.953  0   4
488.875 1300110591.234  2   14.3.2011 14:49:51.234  0   5

I can load it manually, I can also use load -ascii foo.bar but first way is long because of neverending clicking, second one is annoyg because when using load -ascii I have to remove first line with "some text" in it. Right now I have to edit all the files, load them, extract first column and merge them into a matrix.

So my question is: Is there any command, or command routine, that can import this file structure without any need to edit it? I just want data from first column (It's not such a waste of time editing one file)

Thanks for any suggestions.

1

There are 1 best solutions below

0
On BEST ANSWER

The function TEXTSCAN is the way to go. For example:

fid = fopen('foo.bar','r');
data = textscan(fid,'%f %*f %*d %*s %*s %*d %*d','HeaderLines',1);
fclose(fid);
data = data{1};  %# Remove cell array encapsulation

This will skip one header line in the file and ignore the data in columns 2 through 7, returning only the data from the first column in the N-by-1 array data.