我正在尝试使用Matlab中的textscan从文本文件中读取数据。目前,下面提供的代码读取第1到4行。我需要它来读取从5到8的行,然后从9到13的行,依此类推。我将如何实现这一点?
fileID=fopen(fileName);
num_rows=4;
nHeaderLines = 2;
formatSpec = '%*s %*s %s %s %*s %*s %*s %f %*s';
dataIn = textscan(fileID,formatSpec,num_rows,'HeaderLines',nHeaderLines, 'Delimiter',',' );
fclose(fileID);发布于 2014-06-03 01:34:58
使用
file = fopen('myfile');
content = textscan(file,'%s','delimiter','\n');
fclose(file);文件中的所有行都是字符串单元数组。然后取您想要的任意数量的行,并按您喜欢的方式处理它们。
https://stackoverflow.com/questions/23987299
复制相似问题