cell array indexing with logical index bug?
Thorsten Meyer
thorsten.meyier at gmx.de
Sat Nov 1 17:59:43 CDT 2008
Thorsten Meyer 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.
I am more convinced now that it is indeed a bug: I tried in 3.0.1 (debian) and no error occurs.
regards
Thorsten
More information about the Bug-octave
mailing list