[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: str2double behavior
From: |
Ben Abbott |
Subject: |
Re: str2double behavior |
Date: |
Mon, 06 Jun 2011 16:25:00 -0400 |
On Jun 6, 2011, at 2:15 PM, Michael D Godfrey wrote:
> On 06/06/2011 10:57 AM, Ben Abbott wrote:
>> On Jun 6, 2011, at 1:42 PM, Rik wrote:
>>
>>
>>> >
>>> Julien,
>>>
>>> >
>>> >
>>> Can you check what the following does?
>>>
>>> >
>>> >
>>> str2double ({ "1.5", [2.5] })
>>>
>>> >
>>> >
>>> If it returns
>>>
>>> >
>>> >
>>> [ 1.5, NaN ]
>>>
>>> >
>>> >
>>> then Octave will need to look at each value in the cell array. Currently
>>>
>>> > we only check that *all*
>>> values are strings.
>>>
>>> >
>>> >
>>> --Rik
>>>
>> I'm running the same version of Matlab is Julien is.
>>
>>
>>>> >>
>>>> str2double ({ '1.5', [2.5] })
>>>>
>> ans =
>>
>> 1.500000000000000 NaN
>>
>> Ben
>>
>>
> Just for the record, a somewhat newer Matlab says:
>
> >> str2double({'1.5',[2.5]})
>
> ans =
>
> 1.5000 NaN
>
> >> version
>
> ans =
>
> 7.9.0.529 (R2009b)
>
> >>
>> version
ans =
7.11.0.584 (R2010b)
The reason for the different number of digits in the output is because I had
set my "numeric format" set to "long".
>> format short
>> str2double ({ '1.5', [2.5] })
ans =
1.5000 NaN
>> format long
>> str2double ({ '1.5', [2.5] })
ans =
1.500000000000000 NaN
Ben