|
I have a text file that i would like to import into matlab for further use.
The file is initially structured as a data table. However due to the initial compilation stage some of the entries are not valid.
The correct output would all have the same number of columns.
In this case 41 I think. Here is the problem. For some column entries the contents have merged (so not same number of columns) these i want to remove. For other lines sometimes the 'job is aborted' so only one column. This i also want to remove.
e.g.
0.2 0.3 100 200 FIXED 3 4 5 10 10 2E3 3E-4
0.2 0.3 100 200 FIXED 3 4 5 10.110.1 2E3 3E-4
SKIPPED
0.2 0.3 100 200 FIXED 3 4 5 10 NaN 2E3 3E-4
0.2 0.3 100 200 FIXED 3 4 5 10 10 2E3 3E-4
as shown above in line 2 the entry after '5' have joined, line 3 is one column and line 4 contains a NaN
Now for my request....
I thought what i could do is the following....
count the number of lines
read the first and put it into an output array.
Then move onto next, put it in a temporary array and count the number of columns. If this is less than the required discard and move onto next line, else append this to the output array.
I've tried various methods from the help files but often meet with errors due to mived formatting or difference in column sizes.
Any ideas on how to read line 1...then line 2 and so on.
Guess i'm looking for some general code along the lines of...
loop for not eof
read line and pass in array
read next line
Thanks in advance for any help.
|