<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249409</link>
    <title>MATLAB Central Newsreader - Getting values in between the values of a vector?</title>
    <description>Feed for thread: Getting values in between the values of 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>Sun, 19 Apr 2009 18:06:01 -0400</pubDate>
      <title>Getting values in between the values of a vector?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249409#643841</link>
      <author>Brandon Rodriguez</author>
      <description>Say I have a vector that's like this:&lt;br&gt;
&lt;br&gt;
[-6 -3 0 3 6]&lt;br&gt;
&lt;br&gt;
How can I get it get the number in between each of the two values to return something like:&lt;br&gt;
&lt;br&gt;
[-4.5 -1.5 1.5 4.5]&lt;br&gt;
&lt;br&gt;
Is there a built-in function that can do this? I'm asking because I'd like to avoid a loop if possible (but I'm thinking it's the only way). Thanks!</description>
    </item>
    <item>
      <pubDate>Sun, 19 Apr 2009 18:25:03 -0400</pubDate>
      <title>Re: Getting values in between the values of a vector?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/249409#643843</link>
      <author>Jiro Doke</author>
      <description>&quot;Brandon Rodriguez&quot; &amp;lt;coasters2k@yahoo.com&amp;gt; wrote in message &amp;lt;gsfp69$19b$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Say I have a vector that's like this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [-6 -3 0 3 6]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How can I get it get the number in between each of the two values to return something like:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [-4.5 -1.5 1.5 4.5]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there a built-in function that can do this? I'm asking because I'd like to avoid a loop if possible (but I'm thinking it's the only way). Thanks!&lt;br&gt;
&lt;br&gt;
Here are a couple of ways to do it:&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; a = [-6 -3 0 3 6];&lt;br&gt;
&amp;gt;&amp;gt; diff(a)/2 + a(1:end-1)&lt;br&gt;
ans =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-4.5         -1.5          1.5          4.5&lt;br&gt;
&lt;br&gt;
OR&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; (a(1:end-1) + a(2:end))/2&lt;br&gt;
ans =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-4.5         -1.5          1.5          4.5</description>
    </item>
  </channel>
</rss>

