From bug-request at octave dot org Wed Dec 7 14:39:16 2005 Subject: Re: str2num.m can't handle LF character. From: "Frederick (Rick) A Niles" To: Bill Denney Cc: bug at octave dot org, jwe@bevo.che.wisc.edu Date: Wed, 7 Dec 2005 14:29:11 -0600 > str2num('0\n') ans = 0 On Wed, 2005-12-07 at 15:25 -0500, Bill Denney wrote: > I don't think that this is actually an error. str2num should just convert > strings to numbers. If you give it a string that is not strictly numeric > (including all numeric notation such as 1e5-3j), it is supposed to return > empty. > > The problem sounds like it is with how your file is being read. > > Bill > > On Wed, 7 Dec 2005, Frederick (Rick) A Niles wrote: > > > I can't believe no one has come across this one. > > > >> str2num('0\r') > > ans = [](0x0) > > > > > > The problem is that str2num.m is implemented using the eval function and > > the line feed character seems to confuse that we're asking to be eval'd > > > > Anyway, seems like this would be really common when trying to read in > > data from Windows/DOS sources that have "/r" in the line termination. > > > > This there a easy hack to the str2num.m that would make this work for > > me? Should this be fixed in the distro? I'm running 2.1.72. > > > > Thanks, > > > > Rick Niles. > > > > > > > > ------------------------------------------------------------- > > Octave is freely available under the terms of the GNU GPL. > > > > Octave's home on the web: http://www.octave.org > > How to fund new projects: http://www.octave.org/funding.html > > Subscription information: http://www.octave.org/archive.html > > ------------------------------------------------------------- > > > ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------