the first few lines of my text file looks like this:
10/21/2010 16:34:01 360 0.7159 0.716 0.7158 0.7161 40472
10/21/2010 16:35:01 361 0.716 0.7159 0.7157 0.7161 40472 ]
10/21/2010 16:36:01 328 0.7159 0.7162 0.7158 0.7164 40472
the textfile is delimited ,but not by regular characters , is there a way I can import the data into matlab ? I 开发者_JAVA技巧tried it with import wizard , but it would not recognize the data.
You probably can't import the timestamps at the beginning of each line. If you really need the timestamps, convert them to a format where they look like regular numbers (e.g. unix timestamp).
For the rest, you can use the import wizard, set it to "Space" and set "Number of text header lines" to 0.
You can import it by using the textscan, fscanf and perhaps the strtok functions. You can certainly import these time/date marks, but it will require some work to clean up.
This code below will import your file (which looks like it is tab delimited).
fid = fopen('text.txt','r');
raw=textscan(fid,'%s\t%s\t%f\t%f\t%f\t%f\t%f\t%f');
fclose(fid)
date = zeros(1,length(raw{1}));
for i=1:length(d{1})
date(i) = datenum( [ raw{1}{i} ' ' raw{2}{i}] );
end
The dates will be in the date variable and the numeric data in raw{3} ... raw{8}
精彩评论