octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #38317] textread & textscan: different results


From: Stig
Subject: [Octave-bug-tracker] [bug #38317] textread & textscan: different results for empy format strings than MATLAB
Date: Sat, 30 Mar 2013 15:02:38 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 conkeror/1.0pre (Debian-1.0~~pre+git1303272307-~nightly1)

Follow-up Comment #17, bug #38317 (project octave):

I have yet find the Matlab behaviour we are looking at here documented
anywhere, so I am just comparing the results from Octave to the corresponding
results from Matlab.

(The files empty_spots.txt, empty_lines.txt have been attached.)

*Matlab 7.14.0.739 (R2012a)*

>> X = textread('empty_spots.txt', '', 'headerlines', 6)    

X =

         0    5.6900    4.3700    0.5400
    1.0000    0.5800    0.5900    0.0100
    2.0000    0.4300    0.4200         0
    3.0000    0.9300    0.5400    0.3000
    4.0000    0.1200    0.9900    0.7000



*Octave*

octave:1> X = textread('test_textread.txt', '', 'headerlines', 6)
X =

   0.00000   5.69000   4.37000   0.54000
   1.00000   0.58000   0.59000   0.01000
   2.00000   0.43000   0.42000   3.00000
   0.93000   0.54000   0.30000   4.00000
   0.12000   0.99000   0.70000   0.00000



Obviously they don't behave in the same way.

If we take a look at the the file empty_spots.txt, it will be natural (in my
opinion) to think of the the numbers as constituting a 5x4 matrix with one
element missing (at 3,4). This view seems to be in accordance with Matlab's
behaviour, which just fills in a 0 at that position.

Over to empty_lines.txt:

*Matlab 7.14.0.739 (R2012a)*

>> X = textread('empty_lines.txt', '', 'headerlines', 6)  

X =

         0    5.6900    4.3700    0.5400
    1.0000    0.5800    0.5900    0.0100
    2.0000    0.4300    0.4200    0.3000
    3.0000    0.9300    0.5400    0.3000
    4.0000    0.1200    0.9900    0.7000



*Octave*

octave:1> X = textread('empty_lines.txt', '', 'headerlines', 6)
X =

   0.00000   5.69000   4.37000   0.54000
   0.00000   0.00000   1.00000   0.58000
   0.59000   0.01000   0.00000   2.00000
   0.43000   0.42000   0.30000   3.00000
   0.93000   0.54000   0.30000   0.00000
   4.00000   0.12000   0.99000   0.70000
   0.00000   0.00000   0.00000   0.00000
   0.00000   0.00000   0.00000   0.00000



Matlab, as we can see if we compare the output to the content in the input
file, ignores all empty lines, whereas Octave for every empty line adds a 0 to
the resulting matrix. If necessary it (Octave) also fills in more zeros to
complete the last row in the matrix. (If one of the five empty lines at the
end of empty_lines.txt is removed, Octave outputs a 7x4 matrix instead of an
8x4 matrix).

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?38317>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]