title: How is this MATLAB code (involving colon operator) resolved?
body: <p>Recently, I wanted to calculate the next multiple of 5 of several values.
  I was very confused by the output of this code, which <em>should have</em> done the trick:</p>
  <pre><code>7:11 - mod(7:11, 5) + 5
  ans =
      7     8     9    10    11    12    13    14
  </code></pre>
  <p>While the actual working solution was this:</p>
  <pre><code>(7:11) - mod(7:11, 5) + 5
  ans =
  
      10    10    10    15    15
  </code></pre>
  <p>So this seems to be related to operator precedence! But what exactly does the first command do, and why does it output a <code>(1,8)</code> vector?</p>
  <hr />
  <p>Addendum: I have found that the first command can also be written as:</p>
  <pre><code>7:(11 - mod(7:11, 5) + 5)
  </code></pre>
  <p>Which already hints towards the explanation of the observed result, but I am still curious about the whole explanation.</p>