I was tweaking the UI of an old program of mine that (i) reads sets of text files that contain numerical data listed in lines and (ii) extract some numbers from some columns, process them and save these values to another files, that will be used by other programs. As these file readings and data extraction procedures take some time, I changed the program to show the time elapsed between start and end of each data file processing, using tic() and toc(). After this change, the output was very weird. After some investigation, I discovered that after calling PAUSE, the str2num function behaved in a different way, returning the integer part of the strings read from the files. I frequently use some pause calls while writing new code (or changing old code) to read intermediate results, and was being confused by this.
I introduced a very simple test in the code I am running:
<--- Lots of code before ---> disp( 'BEFORE CALLING TIC , str2num(1.99) = ' ) str2num('1.99')
The output of this code shows the strange behavior of str2num:
<--- some output --> BEFORE CALLING TIC , str2num(1.99) = ans = 1.9900 AFTER CALLING TIC: , str2num(1.99) = ans = 1.9900 AFTER CALLING PAUSE: , str2num(1.99) = ans = 1
After this, any subsequent call to str2num produces the same behavior, even in interactive mode, after the program finishes. If I just start octave and try something similar, I can reproduce this erratic behavior, as shown in the next lines
octave:1> str2num('1.991') ans = 1.9910 octave:2> pause octave:3> str2num('1.991') ans = 1
I am using octave 3.0.0, compiled from source on Ubuntu 7.10. Can anyone help me solve this strange behavior?
Thanks, -- Marcus Vinicius Eiffle Duarte address@hidden
NiterĂ³i, RJ, Brasil