From bug-request at octave dot org Tue Jun 7 07:05:10 2005 Subject: Re: Octave/Matlab incompatibility in assignment From: David Bateman To: Tom Holroyd Cc: Keith Goodman , bug@octave.org Date: Mon, 30 May 2005 14:00:51 +0200 Tom Holroyd wrote: > On Tue, 7 Jun 2005, David Bateman wrote: > >> Why should >> >> x = [1,2,3]; index = 0; x(index==0) = 4 >> >> return [4,2,3]? If logical scalar indexing of a matrix makes any >> sense at all I think this should equal [4,4,4].... > > > octave:1> x = [1,2,3]; index = 0; x(index==0) = 4 > x = > > 4 2 3 > > (2.9.3) > > Dr. Tom Holroyd > "A man of genius makes no mistakes. His errors are volitional and > are the portals of discovery." -- James Joyce > Hi Tom, You missed the point "index==0" is 1(logical) -> x(1) = 4..... But "index==1" is 0(logical) so octave interprets the 0(logical) as a 0 index which is out of range, while matlab treats the 0(logical) as a flag whether or not to replace the element 1.... It really is a bit of a crazy behaviour.. D. -- David Bateman David dot Bateman at motorola dot com Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary ------------------------------------------------------------- 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 -------------------------------------------------------------