[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: str2double API changes
From: |
Carnë Draug |
Subject: |
Re: str2double API changes |
Date: |
Sun, 5 Jun 2011 00:06:29 +0100 |
2011/6/4 Rik <address@hidden>:
>> Another change of this function is that if one of the values is not a
>> string, it returns the error: "str2double: wrong type argument `cell'"
>> while it used to simply return the value 'NaN' for those cases.
> Only strings or cellstrings are valid input so there is an implementation
> choice about how to handle bad inputs. How does Matlab handle the following:
>
> str2double ({ "1.5", [2.5] })
>
I don't have MatLab to test whether it returns an error or 'NaN' when
input is not a string. All I could find was "If str does not represent
a valid scalar value, str2double returns NaN." and "the string str".
If MatLab does return 'NaN' when input is not a string, the old
octave's str2double API (which was also completely compatible, just
with more options on top of it) was even more useful because there's
no way now to find if a returned 'NaN' value is a failed conversion
due to input not being a string, or a successful conversion of the
string 'nan' (though now that I think of it, there was never a way to
distinguish between the conversion of a string 'nan' and gibberish).
Anyway, the error should be something more like "one of the cells
doesn't hold a string" rather than "wrong type argument cell" since
cells are valid input values (as long as all the cells hold strings).
Carnë
Re: str2double API changes, Ben Abbott, 2011/06/04