<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303</link>
    <title>MATLAB Central Newsreader - Zeros some value in array</title>
    <description>Feed for thread: Zeros some value in array</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 25 Aug 2009 13:01:05 -0400</pubDate>
      <title>Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675556</link>
      <author>Jaroslav </author>
      <description>Hi, &lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
For example, I have array of 10 numbers A=[1:10]&lt;br&gt;
and result would be look like 0 0 0 4 5 0 0 0 9 10&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Tue, 25 Aug 2009 13:27:02 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675568</link>
      <author>Andy </author>
      <description>&quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h70nah$rkk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; For example, I have array of 10 numbers A=[1:10]&lt;br&gt;
&amp;gt; and result would be look like 0 0 0 4 5 0 0 0 9 10&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
A=1:10;&lt;br&gt;
idx=[1:3 6:8]; % indexes to make zero&lt;br&gt;
A(idx)=0;</description>
    </item>
    <item>
      <pubDate>Tue, 25 Aug 2009 19:42:19 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675704</link>
      <author>Jaroslav </author>
      <description>&quot;Andy &quot; &amp;lt;theorigamist@gmail.com&amp;gt; wrote in message &amp;lt;h70or6$ak0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h70nah$rkk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi, &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 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.&lt;br&gt;
&amp;gt; &amp;gt; For example, I have array of 10 numbers A=[1:10]&lt;br&gt;
&amp;gt; &amp;gt; and result would be look like 0 0 0 4 5 0 0 0 9 10&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A=1:10;&lt;br&gt;
&amp;gt; idx=[1:3 6:8]; % indexes to make zero&lt;br&gt;
&amp;gt; A(idx)=0;&lt;br&gt;
&lt;br&gt;
Thanks Andy,&lt;br&gt;
&lt;br&gt;
but in fact, I will have about 95000 samples. So this way is not what I looking for..&lt;br&gt;
&lt;br&gt;
But thank you..</description>
    </item>
    <item>
      <pubDate>Tue, 25 Aug 2009 20:27:07 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675723</link>
      <author>Andy </author>
      <description>&quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h71eqr$6rf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Andy &quot; &amp;lt;theorigamist@gmail.com&amp;gt; wrote in message &amp;lt;h70or6$ak0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h70nah$rkk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi, &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 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.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; For example, I have array of 10 numbers A=[1:10]&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; and result would be look like 0 0 0 4 5 0 0 0 9 10&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; A=1:10;&lt;br&gt;
&amp;gt; &amp;gt; idx=[1:3 6:8]; % indexes to make zero&lt;br&gt;
&amp;gt; &amp;gt; A(idx)=0;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks Andy,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; but in fact, I will have about 95000 samples. So this way is not what I looking for..&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; But thank you..&lt;br&gt;
&lt;br&gt;
% This approach still works with 95000 samples.  You just want to create idx in&lt;br&gt;
% some way other than explicitly choosing which indexes to remove.&lt;br&gt;
&lt;br&gt;
% Example: create a vector of random data and remove all values below 0.3:&lt;br&gt;
&lt;br&gt;
A=rand(100000,1);&lt;br&gt;
idx=find(A&amp;lt;0.3);&lt;br&gt;
A(idx)=0;&lt;br&gt;
&lt;br&gt;
% If you'd like more help doing this, what are your criteria for determining which&lt;br&gt;
% indexes you want to replace with 0?</description>
    </item>
    <item>
      <pubDate>Wed, 26 Aug 2009 07:15:08 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675808</link>
      <author>Jaroslav </author>
      <description>&quot;Andy &quot; &amp;lt;theorigamist@gmail.com&amp;gt; wrote in message &amp;lt;h71her$1c6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h71eqr$6rf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Andy &quot; &amp;lt;theorigamist@gmail.com&amp;gt; wrote in message &amp;lt;h70or6$ak0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h70nah$rkk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi, &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 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.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; For example, I have array of 10 numbers A=[1:10]&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; and result would be look like 0 0 0 4 5 0 0 0 9 10&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; A=1:10;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; idx=[1:3 6:8]; % indexes to make zero&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; A(idx)=0;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks Andy,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; but in fact, I will have about 95000 samples. So this way is not what I looking for..&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; But thank you..&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % This approach still works with 95000 samples.  You just want to create idx in&lt;br&gt;
&amp;gt; % some way other than explicitly choosing which indexes to remove.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Example: create a vector of random data and remove all values below 0.3:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A=rand(100000,1);&lt;br&gt;
&amp;gt; idx=find(A&amp;lt;0.3);&lt;br&gt;
&amp;gt; A(idx)=0;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % If you'd like more help doing this, what are your criteria for determining which&lt;br&gt;
&amp;gt; % indexes you want to replace with 0?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
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). </description>
    </item>
    <item>
      <pubDate>Wed, 26 Aug 2009 08:47:03 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675824</link>
      <author>Lorenzo Guerrasio</author>
      <description>I'm not sure if I got what you want. take a look, maybe it helps. It's not the best solution, probably.&lt;br&gt;
&lt;br&gt;
my_seq=[0 0 1 1 0];%here you put the sequence of zero you like&lt;br&gt;
my_vect=rand(1,54353);&lt;br&gt;
Nrep=floor(length(my_vect)/length(my_seq));&lt;br&gt;
my_mask=repmat(my_seq,1,Nrep);&lt;br&gt;
my_mask=[my_mask,my_seq(1:(length(my_vect)-length(my_mask)))];&lt;br&gt;
new_vect=my_vect.*my_mask;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Jaroslav &quot; &amp;lt;jaroslav.hrebicek@seznam.cz&amp;gt; wrote in message &amp;lt;h70nah$rkk$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; For example, I have array of 10 numbers A=[1:10]&lt;br&gt;
&amp;gt; and result would be look like 0 0 0 4 5 0 0 0 9 10&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks</description>
    </item>
    <item>
      <pubDate>Wed, 26 Aug 2009 08:50:18 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675825</link>
      <author>us</author>
      <description>&quot;Jaroslav &quot;&lt;br&gt;
&amp;gt; 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)...&lt;br&gt;
&lt;br&gt;
one of the solutions&lt;br&gt;
- for the rand case...&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;n=4;     % &amp;lt;- #data to replace with zeros&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v=1:10;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ix=randperm(numel(v));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v(ix(1:n))=0;&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Wed, 26 Aug 2009 09:03:19 -0400</pubDate>
      <title>Re: Zeros some value in array</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/259303#675827</link>
      <author>us</author>
      <description>&quot;us &quot; &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message &amp;lt;h72t0a$9je$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Jaroslav &quot;&lt;br&gt;
&amp;gt; &amp;gt; 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)...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; one of the solutions&lt;br&gt;
&amp;gt; - for the rand case...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      n=4;     % &amp;lt;- #data to replace with zeros&lt;br&gt;
&amp;gt;      v=1:10;&lt;br&gt;
&amp;gt;      ix=randperm(numel(v));&lt;br&gt;
&amp;gt;      v(ix(1:n))=0;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; us&lt;br&gt;
&lt;br&gt;
unfortunately, the second part got lost in the copy/paste process...&lt;br&gt;
&lt;br&gt;
one of the solutions&lt;br&gt;
- for the rand case...&lt;br&gt;
...&lt;br&gt;
- for the periodic case&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;v=1:16;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tmpl=[0,0,1,1];     % &amp;lt;- min block of zeros/data with numel(v) = N x numel(tmpl)!&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r=reshape(bsxfun(@times,reshape(v,numel(tmpl),[]).',tmpl).',1,[]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp([v;r]);&lt;br&gt;
%{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0  0  3  4  0  0  7  8  0  0 11 12  0  0 15 16&lt;br&gt;
%}&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
  </channel>
</rss>

