[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding the other elements in array or matrices
From: |
Marc Normandin |
Subject: |
Re: Finding the other elements in array or matrices |
Date: |
Tue, 15 Jan 2008 22:09:40 -0500 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071022) |
pauljoseph wrote:
> Hi,
> Can someone help me on how to do this effectively in Octave?
>
> for example I have an array:
> a=[10,20,30,40,50];
>
> and I have another list
> mask=[1,4];
>
> if I type
> a(mask)
>
> , I will get:
> 10, 40
>
> But what I want to get is the other elements which is 2,3, and 5, which
> gives
> 20,30,50
>
> And what I have in hand is only a and mask.
>
> I would appreciate your help :)
> --
> View this message in context:
> http://www.nabble.com/Finding-the-other-elements-in-array-or-matrices-tp14859516p14859516.html
> Sent from the Octave - General mailing list archive at Nabble.com.
There's likely to be a more efficient way to handle this problem, but
here's one possible solution.
mask2=1:length(a);
mask2(mask)=0;
idx=find(mask2);
a(idx)
The same idea can be extended to matrices, however its implementation
will depend upon how the mask is defined.
Regards,
Marc