<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168778</link>
    <title>MATLAB Central Newsreader - shifting data within a vector</title>
    <description>Feed for thread: shifting data within a vector</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>Mon, 05 May 2008 22:58:03 -0400</pubDate>
      <title>shifting data within a vector</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168778#430451</link>
      <author>Hydroman S</author>
      <description>For a vector s, I found its maximum value, and located it&lt;br&gt;
&lt;br&gt;
s=rand(20,1);&lt;br&gt;
max(s);&lt;br&gt;
find(s==max(s));&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Now I want to add a value of say x=10; to the max(s) and &lt;br&gt;
place it in the following row(raw after max(s)), then add &lt;br&gt;
a value of 20 to the max(s)and add it to the following &lt;br&gt;
raw....etc till the end raw?&lt;br&gt;
&lt;br&gt;
Any suggestions?  </description>
    </item>
    <item>
      <pubDate>Mon, 05 May 2008 23:28:04 -0400</pubDate>
      <title>Re: shifting data within a vector</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168778#430454</link>
      <author>Roger Stafford</author>
      <description>&quot;Hydroman S&quot; &amp;lt;amirgsalem@gmail.com&amp;gt; wrote in message &amp;lt;fvo3dr$8qk&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; For a vector s, I found its maximum value, and located it&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; s=rand(20,1);&lt;br&gt;
&amp;gt; max(s);&lt;br&gt;
&amp;gt; find(s==max(s));&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Now I want to add a value of say x=10; to the max(s) and &lt;br&gt;
&amp;gt; place it in the following row(raw after max(s)), then add &lt;br&gt;
&amp;gt; a value of 20 to the max(s)and add it to the following &lt;br&gt;
&amp;gt; raw....etc till the end raw?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any suggestions?  &lt;br&gt;
-----------&lt;br&gt;
&amp;nbsp;&amp;nbsp;First of all, you don't need 'find' here.  Just use the index returned by max:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;[mx,ix] = max(s); % ix is the index of the maximum element of x&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;The rest of what you are asking is rather hard to interpret.  Your misuse of &lt;br&gt;
the word 'raw' is confusing!  My guess is that, starting with ix+1, you wish to &lt;br&gt;
place mx+10, mx+20, ..., in ix+1, ix+2, etc., on to the end of s.  Is that it?&lt;br&gt;
&lt;br&gt;
&amp;nbsp;s(ix+1:end) = mx+(10:10:10*(length(s)-ix))';&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Mon, 05 May 2008 23:35:00 -0400</pubDate>
      <title>Re: shifting data within a vector</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168778#430456</link>
      <author>Roger Stafford</author>
      <description>&quot;Roger Stafford&quot; &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fvo564$i8p$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;   First of all, you don't need 'find' here.  Just use the index returned by max:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  [mx,ix] = max(s); % ix is the index of the maximum element of x&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   The rest of what you are asking is rather hard to interpret.  Your misuse &lt;br&gt;
of &lt;br&gt;
&amp;gt; the word 'raw' is confusing!  My guess is that, starting with ix+1, you wish &lt;br&gt;
to &lt;br&gt;
&amp;gt; place mx+10, mx+20, ..., in ix+1, ix+2, etc., on to the end of s.  Is that it?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  s(ix+1:end) = mx+(10:10:10*(length(s)-ix))';&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
-------&lt;br&gt;
&amp;nbsp;&amp;nbsp;After looking at your wordage again, it seems possible that what you &lt;br&gt;
actually want is this:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;[mx,ix] = max(s); % ix is the index of the maximum element of x&lt;br&gt;
&amp;nbsp;s(ix+1:end) = s(ix+1:end) + mx+(10:10:10*(length(s)-ix))';&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Tue, 06 May 2008 03:38:03 -0400</pubDate>
      <title>Re: shifting data within a vector</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168778#430473</link>
      <author>Hydroman S</author>
      <description>Thank you Roger.  Your first reply answers my question.  &lt;br&gt;
Apologies for the &amp;#8216;raw&amp;#8217; stuff, sometimes this stuff comes &lt;br&gt;
from the gut instead of the brain.&lt;br&gt;
&lt;br&gt;
Here is exactly what I wanted to do, and thanks again for &lt;br&gt;
your help:&lt;br&gt;
&lt;br&gt;
s=rand(20,1);&lt;br&gt;
[mx,ix] = max(s); % ix is the index of the maximum element &lt;br&gt;
of x&lt;br&gt;
s(ix+1:end) = mx+(10:10:10*(length(s)-ix))';&lt;br&gt;
s(1:ix-1)= mx-(10:10:10*(ix-1))';</description>
    </item>
  </channel>
</rss>

