cell array indexing with logical index bug?
Ben Abbott
bpabbott at mac.com
Sun Nov 2 01:25:06 CST 2008
On Nov 2, 2008, at 1:19 AM, Jaroslav Hajek wrote:
> On Sat, Nov 1, 2008 at 11:54 PM, Thorsten Meyer <thorsten.meyier at gmx.de
> > wrote:
>> Hi,
>>
>> with octave built from the current tip I get:
>>
>>
>> octave:1> a{1}=1
>> a =
>>
>> {
>> [1,1] = 1
>> }
>>
>> octave:2> a(1)=[]
>> a = {}(1x0)
>> octave:3> a{1}=1
>> a =
>>
>> {
>> [1,1] = 1
>> }
>>
>> octave:4> a(1==1)=[]
>> error: A(I): Index exceeds matrix dimension.
>> octave:4> a{1}=1;a{2}=2;
>> octave:5> a(1==1)=[]
>> a =
>>
>> {
>> [1,1] = 2
>> }
>> octave:6> a{1}=1;a{2}=2;
>> octave:7> a([1 2])=[]
>> error: A(I): Index exceeds matrix dimension.
>>
>> So I can empty a cell array indexing with single index of type
>> double, but not with a single index
>> of type logical. If the index is a vector, it does not matter if it
>> is double or logical.
>>
>> I am not sure if this is a bug. Imho, it is at least a misfeature:
>> e.g., when I want to eliminate
>> entries of a by a certain criterion, i could do:
>> idx = cellfun (@(x) x>0, a);
>> a(idx) = [];
>> But with the above behaviour I have to specially treat the case
>> that all elements of a fulfil the
>> criterion.
>>
>> regards
>>
>
> Though I can't reproduce it, please try this patch:
> http://hg.savannah.gnu.org/hgweb/octave/rev/f7d44b6a74df
>
> regards
I just can verify this behavior exists on Mac OSX . My tip is
changeset: 8300:4b9bce36109b
tag: tip
user: David Bateman <dbateman at free.fr>
date: Fri Oct 31 17:41:57 2008 +0100
summary: Add constraint for logical image cdata
I'll pull and build again.
Ben
More information about the Bug-octave
mailing list