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: anonymous
Subject: [Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead of NaN
Date: Fri, 23 Aug 2013 17:59:55 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1

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

The behavior that `str2double({})` ==> `[]` is actually correct.  The
rationale being that you have given a cell array containing no strings to
convert, and that you should therefore get a list of no numbers in response.

Arguably, the `str2double('')` case is also documented to return an empty
value,  since rows of a matrix are documented as being interpreted separately,
and the empty string is 0x0 so has no rows.  Note that
`str2double(char(zeros(n,0)))` gives `nan(n,1)` in octave.  However, as you
observe, this differs from MATLAB's behavior, which is to return a single NaN
for any empty string (i.e. anything with a zero dimension).

MATLAB's behavior also differs on _any_ input that is not of char or cell
type; octave returns `nan(size(input))`, while matlab returns `nan(1)`.

    _______________________________________________________

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]