Textscan from end of line

60 views Asked by At

I am trying to read a very heavy file. On each line I have some integers but the numbers of integers is not known. I just want to extract the last n items. I couldn't find the right syntax for doing this.

Example:

lineA='10 200 300 400 500';
lineB='300 400 500 550';
pA=textscan(lineA,'%u %u %u');
pB=textscan(lineB,'%u %u %u');

The results should be:

pA={[300]}    {[400]}    {[500]}
pB={[400]}    {[500]}    {[550]}

Currently I am not able to know the size of each line and I want to avoid having to. On this example I just read lines but in my actual script I read a file with 10e6 lines and I use the syntax textscan(fid,format,10e6).

0

There are 0 answers