How to ignore letters while using fscanf?
Show older comments
I have data sets that are text file that look something like this:
Area Mean Min Max
1 25 239 170 351
2 25 250.120 155 442
3 25 259.360 159 477
I have been using a code that uses fscanf to read these files into arrays. However, I have to delete the header of the text files for it to work properly. Here is the bit of code with fscanf:
fprintf('\n reading in .txt file')
if nFile > 1
filename = filenameAll{dataind};
formatSpec = '%f%f%f%f%f%[^\n\r]';
fid = fopen([pathname filename]);
rawdata=fscanf(fid, '%f %f %f %f %f', [6 inf]);
rawdata=rawdata';
else
fid = fopen([pathname filenameAll]);
rawdata=fscanf(fid, '%f %f %f %f %f', [6 inf]);
rawdata=rawdata';
end
Is there a way to "tell" the code to ignore alphabetical letters? Or instead, to remove the letters before using fscanf?
Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!