Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Zeros some value in array
Date: Tue, 25 Aug 2009 20:27:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <h71her$1c6$1@fred.mathworks.com>
References: <h70nah$rkk$1@fred.mathworks.com> <h70or6$ak0$1@fred.mathworks.com> <h71eqr$6rf$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1251232027 1414 172.30.248.37 (25 Aug 2009 20:27:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 25 Aug 2009 20:27:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1895050
Xref: news.mathworks.com comp.soft-sys.matlab:565952


"Jaroslav " <jaroslav.hrebicek@seznam.cz> wrote in message <h71eqr$6rf$1@fred.mathworks.com>...
> "Andy " <theorigamist@gmail.com> wrote in message <h70or6$ak0$1@fred.mathworks.com>...
> > "Jaroslav " <jaroslav.hrebicek@seznam.cz> wrote in message <h70nah$rkk$1@fred.mathworks.com>...
> > > Hi, 
> > > 
> > > how could I zeros some numbers in array? I need replace for example first three numbers by zeros, then keep original 2 numbers and then again replace next three numbers by zero etc.
> > > For example, I have array of 10 numbers A=[1:10]
> > > and result would be look like 0 0 0 4 5 0 0 0 9 10
> > > 
> > > Thanks
> > 
> > A=1:10;
> > idx=[1:3 6:8]; % indexes to make zero
> > A(idx)=0;
> 
> Thanks Andy,
> 
> but in fact, I will have about 95000 samples. So this way is not what I looking for..
> 
> But thank you..

% This approach still works with 95000 samples.  You just want to create idx in
% some way other than explicitly choosing which indexes to remove.

% Example: create a vector of random data and remove all values below 0.3:

A=rand(100000,1);
idx=find(A<0.3);
A(idx)=0;

% If you'd like more help doing this, what are your criteria for determining which
% indexes you want to replace with 0?