From bug-octave-request at bevo dot che dot wisc dot edu Tue Feb 3 14:52:08 1998 Subject: Array select bug(feature)? From: "John W. Eaton" To: U-E59264-Osman Buyukisik Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 3 Feb 1998 14:52:00 -0600 On 3-Feb-1998, U-E59264-Osman Buyukisik wrote: | octave-2.0.9.96 with gcc/f2c on hpux-10.20 : | | | x=[1,2,3,4,5,6]' | mask1=[1,0,1,0,1,1]' | mask2=[1,1,1,1,1,1]' | x(mask2) gives me different results on octave and matlab. | octave : | | octave:53> x(mask2) | ans = | | 1 | 1 | 1 | 1 | 1 | 1 | | On Matlab : | >> x(mask2) | | ans = | | 1 | 2 | 3 | 4 | 5 | 6 | | Which is the expected result. However x(mask1) is the same on both | systems! | Bug/feature? I am trying to convert matlab scripts. Bug (in Matlab) because when the mask is all ones and the same size as the array that's being indexed, the meaning of the operation is ambiguous. Octave allows you to choose the meaning you prefer, by giving you the prefer_zero_one_indexing variable. Set it to 1 and Octave will be compatible with Matlab's behavior. jwe