[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60711] textscan with '.' char read as float
From: |
Paul Netsaver |
Subject: |
[Octave-bug-tracker] [bug #60711] textscan with '.' char read as float |
Date: |
Wed, 2 Jun 2021 16:55:10 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 |
Follow-up Comment #2, bug #60711 (project octave):
>>I'm not sure why Matlab decides there are two values here when the delimiter
was clearly specified to be the comma ','.
I think the problem is not the delimiter, it is the dot.
Replace the dot with another char, e.h. 'a':
>> q=textscan([',,a,,3'],'%f','delimiter',',')
q =
{
[1,1] =
NaN
NaN
}
You see that textscan stops when doesn't find a match (this results is the
same in Octave and Matlab), while NaN does not stop the scan as it's a match
with an EmptyValue.
I think that the true difference is that according to Matlab the dot '.' does
not match a float '%f' (therefore stops the scan and does not read the
following NaNs), while Octave does match with a NaN float, irrespective of the
delimiter.
Probabily Octave starts a matching with '.' waiting for a number (e.g. '.0')
and initializes a NaN, then when it finds the limiter and cannot convert to a
number leaves the NaN.
Matlab instead understands that '.' alone cannot resolve to a number (even
empty) and stops the scan.
By the way I can resolve with a dedicated check, it was only to understand if
this was the expected behavior or not.
Thanks and regards,
Netsaver
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60711>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/