From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: logical indexing with larger logical array
Date: Fri, 05 Nov 2010 11:06:13 -0500
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <ib1aab$lo9$>
References: <ib0jl3$6es$> <ib0lbg$p9c$> <ib0vne$6lh$> <ib11rk$k4p$> <ib139n$3bh$> <ib14sb$kbp$>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2010 16:10:52 +0000 (UTC)
Injection-Info:; posting-host="t7YQg5oy1WBTQEoqpvq/DA";
	logging-data="22281"; mail-complaints-to="";	posting-account="U2FsdGVkX199hpzd9OVWyrHugqwfRUau"
User-Agent: Thunderbird (Windows/20100228)
In-Reply-To: <HIDDEN>
Cancel-Lock: sha1:bsdRR6PpJ6UO0muUzs2V6fB3tyo=
Xref: comp.soft-sys.matlab:684192

Bruno Luong wrote:
> To me it looks like the logical indexing engine performs the bound 
> checking with *every* elements that corresponds to TRUE. That's why it 
> issues an error with outside TRUE and not outside FALSE. If the checking 
> is performed once before the scan on the sizes of the array and the 
> logical array, there might be some speed gain.
> I agree that the virtue of being able of passing FALSE beyond the limit 
> is ...none. It likely a bug of the program when such calling occurs, and 
> the programmer should be alerted.
> When the logical array is shorter, Matlab pads the missing tail with 
> FALSE. This behavior is documented and useful.
> In any case, the behavior when invoking with longer logical array must 
> be documented.

The "bad" behavior imo is this (sticking w/ David's example) --

 >> a(l(size(a)))
ans =
      1     3
 >> a(l)
ans =

The behavior of concatenating 'false' in shorter in vectors is clear; 
what is perverse is the conversion to linear indexing in the 2D (and 
presumably higher altho I didn't check it) that returns a somewhat 
surprising result when the logic array is mapped onto the indexed array.

IMO it's too bad the behavior wasn't codified as in the first of the two 
snippets above but I'd consider not breaking old code probably of higher 
import than fixing the behavior at this point.