0

我正在尝试使用textscanMatlab 从文本文件中读取数据。目前,下面提供的代码读取第 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);
4

1 回答 1

0

利用

file = fopen('myfile');             
content = textscan(file,'%s','delimiter','\n');
fclose(file);

并且您将文件中的所有行都作为字符串元胞数组。然后取任意数量的行并根据需要处理它们。

于 2014-06-02T17:34:58.170 回答