help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading data from ascii files.


From: Massimiliano Minella
Subject: Re: reading data from ascii files.
Date: Mon, 19 Jul 2010 04:56:53 -0700 (PDT)

Since you already read completely the file to get the number of rows, why you
don't simply get the values from the string you read with fgetl?

If you replace this loop


Veloci wrote:
> 
> 
> rnum = 0;
> while (feof(fid)~= 1)
>   rnum = rnum + 1;
>   l = fgetl (fid);
> end;
> 
> 

with something like this 

rnum = 0;
while (feof(fid)~= 1)
  rnum = rnum + 1;
  l = fgetl (fid);
  [val{i}] = sscanf(l, "%f %f %f %f");
end;

and after the loop you use the command "cell2mat" in order to concatenate
the cell into a matrix you maybe could get a little improvement (in my case
it did).

Max


-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/reading-data-from-ascii-files-tp2291167p2293862.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]