首页 > 解决方案 > 从matlab中的文件读取时如何跳过前几行

问题描述

我正在从“Data.raw”文件中读取我的数据,但我对如何跳过前 2 行一无所知。我已经编写了一个从文件中读取的程序。如果您能告诉我如何跳过前几行并仅从第三行获取数据,我将不胜感激。

%Reading the Text File
fileID = fopen('Data.raw');
TSOutput = textscan(fileID,'%f %f %f %f/n' );

count = 0;
while not(feof(fileID))
    count = count + 1;
    readData = textscan(fileID,'%f %f %f %f/n');
    
    if feof(fileID)
        break;
    end
    
    TSOutput = [TSOutput; readData];
end

我的数据文件:

# Z  TALLY_DATA 260
#  L  M  N  Y
1 1 0 -6.291667
1 1.003333 0 -0.2748109
1 1.003333 0.1 -0.2748109
1 1 0.1 -6.291667
1 1.006667 0 0.8322136
1 1.006667 0.1 0.8322136
1 1.01 0 1.501634

标签: matlab

解决方案


推荐阅读