load a file and sort out bad data.
Show older comments
I have a text file like shown below, that I want to load in to matlab. The format of the file should be like: [temp rate type], but if some of the data is not in correct format i want them sorted out. For example a file could look like this:
25 0.109 1
corrupted line
20 0.096 2
100 0 3
15 0.517 3
15 0.8 5
35 1.086 4
3
40 0.934 2
3 3 3 3 3 3
35 0.109 1
22 0.100 1
21 0.100 2
16 0.600 3
17 0.850 5
32 1.080 4
45 0.950 2
37 0.110 1
Any letters and lines that are not in correct format ( 3 numbers per line) should be ignored, when loading the file. How can I do this? I have tried different combinations of fgetl(), scanf(), and textscan(), but I am not sure how to do it. Please help me if you can.
Adam
Accepted Answer
More Answers (1)
1 Comment
Jason Nicholson
on 17 Jun 2014
Your welcome.
Categories
Find more on Shifting and Sorting Matrices 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!