0

I am reading my data from 'Data.raw' file but I am clueless on how to skip the first 2 rows. I have already written a program to read from the file. I would be grateful if you could kindly tell me how to skip the first few rows and fetch only the data from the third row.

%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

My Data file:

# 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
James Z
  • 12,209
  • 10
  • 24
  • 44
Smalbro93
  • 3
  • 3
  • There is a `headerlines` property for the `textscan` function. Check the `textscan` documentation of have a look at this question: [MATLAB textscan headerlines](https://stackoverflow.com/q/14172563/3460361). – Hoki Aug 17 '20 at 08:37
  • Hoki san, thank you very much. That works and answers the question. Thank you. – Smalbro93 Aug 17 '20 at 09:10

0 Answers0