From: jmeccles Eccles on
I'm using textscan to read in formatted data from text files. However the files don't have a set number of lines of data. The textfiles have a set amount of header lines (which I am using the 'headerlines' option in textscan to skip), then there is a random number of data lines. Then after the data lines, there is one more line that isn't formatted data.

I need to know how to use textscan to read in all of the data, and stop after the last line of actual data. I was thinking of using a while loop, and when the end of the data is reached, just end the loop. But if there is something simpler, please let me know.

while i>0
datainfo=textscan(fid, '%s', 5, 'headerlines', 1);
end

I guess i just need an if statement in there determining if I've reached the end of the actual data.

Any help is appreciated,

Thanks.
From: us on
"jmeccles Eccles" <jared.eccles(a)hotmail.com> wrote in message <hmrgrq$52h$1(a)fred.mathworks.com>...
> I'm using textscan to read in formatted data from text files. However the files don't have a set number of lines of data. The textfiles have a set amount of header lines (which I am using the 'headerlines' option in textscan to skip), then there is a random number of data lines. Then after the data lines, there is one more line that isn't formatted data.
>
> I need to know how to use textscan to read in all of the data, and stop after the last line of actual data. I was thinking of using a while loop, and when the end of the data is reached, just end the loop. But if there is something simpler, please let me know.
>
> while i>0
> datainfo=textscan(fid, '%s', 5, 'headerlines', 1);
> end
>
> I guess i just need an if statement in there determining if I've reached the end of the actual data.
>
> Any help is appreciated,
>
> Thanks.

why do you not simply read the whole file in one shot(?)...

us
 | 
Pages: 1
Prev: MATLAB code speed
Next: New generator