Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!news.stack.nl!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: deleting elements from vector
Date: Tue, 25 Dec 2012 01:14:08 -0600
Organization: Aioe.org NNTP Server
Lines: 27
Message-ID: <kbbjoc$1om$1@speranza.aioe.org>
References: <kbbjar$5g6$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: 2CibzTqnux2ggoH9QofcGw.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:785351

On 12/25/2012 1:07 AM, Shobana wrote:
> hai friends...
>     I need to delete some values in the vector based on the values in the another vector
> for example:
>    e = [1 1 0 0 2 3 , .  . . . n]
>    a = [1 2 3 4 5 6 ...........n]
> the result should be like this b = [1 2 5 6.....n] the value of 'a' corresponding
>to the place where e = = 0 should be removed.I tried like this
> for j  =1:length(e)
>    if(e == 0)
>     data[j] = [];
> end
> end
>
> but it gives wrong answer like [1 2 4 6..n] .here the length of 'a' and 'e' are same.
>please reply me as soon as possible
>
>

EDU>> e = [1 1 0 0 2 3]
EDU>> a = [1 2 3 4 5 6]
EDU>> a(e==0)=[]

      1     2     5     6

--Nasser