Hello everyone,
I am currently having difficulties trying to read a text file in Matlab. A small example is shown below.
My aim is to;
-Open the file
-Ignore the header (first n lines)
-Replace the Bad entries with NaN
-Replace any corrupted entries with NaN (as entry (3,1))
—-
I tried the following code with which I had some success if I removed the header first but I am struggling to get it all to work together.
buffer=fileread('C:\Users\Jack\Desktop\ContourGT\13.07.2013_header_removed.txt);
buffer = strrep(buffer, 'Bad', 'NaN') ;
surface=sscanf(buffer, '%f',[width length]);
—
Wyko ASCII Data File Format 0 0 1
X Size 640
Y Size 3015
Block Name Type Length Value
Wavelength 7 4 200.746124
Bad Bad Bad Bad Bad Bad
Bad -15216.897461 Bad Bad Bad Bad
-15s83.3t93555 Bad Bad Bad Bad Bad
Bad Bad -15169.881836 Bad Bad Bad
Bad Bad Bad Bad Bad Bad
Bad Bad Bad Bad Bad Bad
—
Any ideas? Any thoughts would be gratefully appreciated.
Thanks in advance
Jack
Best Answer