Wednesday, February 24, 2010

textread and ignoring columns

okay, say you have a .csv file (comma separated variable, excel likes those) and for come reason you don't want to use csvread. i found textread to be more flexible.

roka collected some data that has 22 headerlines, and then 4 columns of data. i only care about the first column of data. so this is what i used to read in the file:

[kilograms] = textread(namestr,'%f %*f %*f %*f', 'delimiter', ',', 'headerlines',22);

namestr is set to the name of the file, e.g. '090512.csv'
%f indicates that the data are floating point numbers
the *s indicate that i am skipping the last three columns of floating point data
there are several options for the delimiter, in my case it is commas ','
there are 22 headerlines before the data starts. 

more data i/o, woo.

anyway, i just went to make the links to textread and matlab says that it recommends textscan over textread. oh well. 

No comments:

Post a Comment