Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Zeros some value in array
Date: Wed, 26 Aug 2009 09:03:19 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 31
Message-ID: <h72ton$95j$1@fred.mathworks.com>
References: <h70nah$rkk$1@fred.mathworks.com> <h70or6$ak0$1@fred.mathworks.com> <h71eqr$6rf$1@fred.mathworks.com> <h71her$1c6$1@fred.mathworks.com> <h72nds$8jl$1@fred.mathworks.com> <h72t0a$9je$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1251277399 9395 172.30.248.35 (26 Aug 2009 09:03:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 26 Aug 2009 09:03:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:566056


"us " <us@neurol.unizh.ch> wrote in message <h72t0a$9je$1@fred.mathworks.com>...
> "Jaroslav "
> > It does not matter, what indexes will be replaced with 0. But the number of  0 must be always same and this interval of zeros should be repeated randomly or periodically up to end of samples (in array)...
> 
> one of the solutions
> - for the rand case...
> 
>      n=4;     % <- #data to replace with zeros
>      v=1:10;
>      ix=randperm(numel(v));
>      v(ix(1:n))=0;
> 
> us

unfortunately, the second part got lost in the copy/paste process...

one of the solutions
- for the rand case...
...
- for the periodic case

     v=1:16;
     tmpl=[0,0,1,1];     % <- min block of zeros/data with numel(v) = N x numel(tmpl)!
     r=reshape(bsxfun(@times,reshape(v,numel(tmpl),[]).',tmpl).',1,[]);
     disp([v;r]);
%{
          1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
          0  0  3  4  0  0  7  8  0  0 11 12  0  0 15 16
%}

us