help-octave
[Top][All Lists]
Advanced

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

Re: NaN


From: Paul Laub
Subject: Re: NaN
Date: Thu, 18 Nov 2004 17:43:45 -0800

Matt, 

Instead of fscanf(), you might try fgets() followed by str2num(). The
following lines work for me even when file.txt contains a NaN. (I am
using Octave 2.1.57 running on Cygwin and Windows 2000.)  This is not
likely to be an efficient method, but it might suffice.

fid = fopen("file.txt", "r");
str = fgets(fid);  # read one line from the opened file
row_vector_of_data = str2num(str); 

Hope this helps, 

Paul Laub 


On Thu, 18 Nov 2004 17:33:13 +0000, Matt Funk <address@hidden> wrote:
> Hi all,
> 
> I am trying load a 2D vector from a text file that was actually saved out by
> another octave script via the save fcn. Anyway, the load() didn't work so i
> used fscanf. That works fine, and it reads all the values in correctly until
> i hit the first NaN in the vector (there are several) and after that it
> doesn't read correctly anymore. In fact it reads all zeros after that
> regardless if it's a NaN or a good value.
> 
> Are there any quick fixes for this situation. It'd be REALLY nice if i could
> read those in since i have a lot of files to read in.
> 
> Also, when i used the load() fcn it read something in but it is a 1x1 entity,
> whereas my vector is something like 10x25. Looking at that thing it prints
> the right vector on the terminal, but i can't index it as a vector (obviously
> since it is a 1x1)
> 
> so, any fixes?
> 
> thanks
> mat
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
> 


-- 

Safe Harbor Disclaimer: "Elvis has left the building."



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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