cell array indexing with logical index bug?
Jaroslav Hajek
highegg at gmail.com
Sun Nov 2 00:19:43 CDT 2008
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
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
More information about the Bug-octave
mailing list