octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead


From: Philip Nienhuis
Subject: [Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead of NaN
Date: Sun, 25 Aug 2013 20:09:50 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6

Follow-up Comment #5, bug #39838 (project octave):

As to 3x1 => 2x1 char array, you're quite right, ML does the same (never
noticed, I very rarely work with char arrays).
My point was that char type input arrays for str2double can be
"machine-generated", and anything beyond str2double in the processing order
can be unpleasantly surprised by silently adapted dimensions. But I do think
cell arrays are more suited for this kind of thing; the dimensions for char
arrays are adapted as soon as one char array element is empty -str2double
isn't even required-, cell arrays are immune to this.

Before you make your patch, do note that ML's docs for str2double (r2013b
prerelease) do not (explicitly) mention char arrays, only cell arrays. (For
str2num, char arrays are explicitly mentioned, but not cell arrays; same for
e.g., hex2num.)
In this respect it may be enlightening to see what ML's str2double does with
char arrays:

>> str2double (['1'; ''; '3'])

ans =

    13

>> str2double (['1 + 0.5i'; '';])

ans =
   1.0000 + 0.5000i

>> str2double (['1 + 0.5i'; ''; '3 + 2.1i'])

ans =

   NaN


.... so Matlab's str2double even treats a char array as one long string (IOW
it doesn't recognize char arrays); again quite different from Octave. Maybe
that's why it returns a scalar NaN for an "unparsable" char array.

My offer to adapt str2double's help text still stands. I'll await your patch,
I might have time next Tuesday evening.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?39838>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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