[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Handling unusual number conditions
From: |
Geraint Paul Bevan |
Subject: |
Re: Handling unusual number conditions |
Date: |
Tue, 06 Sep 2005 09:33:38 +0100 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20050817) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Madhusudan Singh wrote:
> Hi
>
> My measurement sometimes generates some unusual numbers. In the data file,
> this sometimes reads as :
>
> Overflow
>
> in a column full of numbers.
>
> Can Octave handle this gracefully in some fashion ? The way I read in data is
> to read one line at a time, and then apply str2num to that string to extract
> the numbers.
>
> And the output of the measurement *cannot* be modified. So any suggestions
> other than that could be useful.
>
> Thanks.
You can use strrep to replace all occurances of "Overflow" with "NaN"
(not a number) which str2num will happily accept:
octave> string = "1 2 3 4 5 Overflow 7"
string = 1 2 3 4 5 Overflow 7
octave> string = strrep(string, "Overflow", "NaN")
string = 1 2 3 4 5 NaN 7
octave> str2num(string)
ans =
1 2 3 4 5 NaN 7
- --
Geraint Bevan
http://homepage.ntlworld.com/geraint.bevan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iEYEARECAAYFAkMdVGIACgkQcXV3N50QmNMKXQCfWaXSGJqTNlu42FsiYWxIXZHq
eYwAnjD1XdwU+y1ZrajHuP31Yf7xSvo5
=6Q7t
-----END PGP SIGNATURE-----
-------------------------------------------------------------
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
-------------------------------------------------------------