how to load a file with header

my file has one header
for example, my file name is gobang_no_aircon_20130729.dat
Matlab time = labVIEW(time)/(24*60*60)+datenum('1904-0101','yyyy-mm-dd');
3457900800.00000 0 0 0 27.8300000000000 0
3457900805.00000 0 0 0 27.8300000000000 0
3457900810.00000 0 0 0 27.8300000000000 0
...
I want to load this file but ,because of the header, I can't please tell me how to load this file

Answers (1)

fid = fopen('gobang_no_aircon_20130729.dat', 'r');
datacell = textscan(fid, '%g%g%g%g%g%g', 'headerlines', 1, 'collect', 1);
fclose(fid);
data_array = datacell{1};

6 Comments

>> fid = fopen('gobang_no_aircon_20130729.dat','r');
>> datacell = textscan(fid, '%g%g%g%g%g%g','headerlines', 1 , 'collect', 1);
I put just like this, but I got
*??? Error using ==> textscan Invalid file identifier. Use fopen to generate a valid file identifier. *
what is my problem??
You must not have a file named gobang_no_aircon_20130729.dat in your local directory. Try
data_array = 'file not opened';
[fid, msg] = fopen('gobang_no_aircon_20130729.dat','r');
if fid < 0; fprintf('open failed because: %s\n', msg);
else
datacell = textscan(fid, '%g%g%g%g%g%g', 'headerlines', 1, 'collect', 1);
fclose(fid);
data_array = datacell{1};
end
I got
??? Error using ==> textscan Unknown option 'collect'.
what is it..?
You might have to spell it out in full; it is 'CollectOutput'
I already put collectOutput but it said "bad string"
@hyumin: If you read the documentation of textscan(), you will find all required information. It would not be efficient to ask Walter to re-tell, what you can read there.

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 6 Aug 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!