我想在MATLAB中读取这个文件,该文件包含这些数据
1/1/2008 1110 98.5
1/2/2008 1110 99.5
1/3/2008 1110 96.5
1/4/2008 1110 32.5
1/5/2008 1110 8.56
1/6/2008 1110 48.5
它应该分为五列:
答案 0 :(得分:5)
使用TEXTSCAN功能:
%# parse file (change the data types if necessary)
fid = fopen('file.dat','rt');
C = textscan(fid, '%d/%d/%d %d %f', 'Delimiter',' ');
fclose(fid);
%# put columns in separate variables
[dt_month,dt_day,dt_year,val1,val2] = deal(C{:});
%# convert to serial date
dt = datenum(double(dt_year),double(dt_month),double(dt_day));