title: Calculate mean of columns only
body: <p>I have a function that calculates the mean of two columns of a matrix. For example, if the following matrix is the input:</p>
  
  <pre><code>inputMatrix =
  
                  1   2   5   3   9
                  4   6   2   3   2
                  4   4   3   9   1
  </code></pre>
  
  <p>... And my command is:</p>
  
  <pre><code>outputVector = mean(inputArray(:,1:2))
  </code></pre>
  
  <p>...Then my output is:</p>
  
  <pre><code>outputVector = 
  
                  3   4
  </code></pre>
  
  <p>The problem arises when my input matrix only contains one row (i.e. when it is a vector, not a matrix).</p>
  
  <p>For example, the input:</p>
  
  <pre><code>inputMatrix =
  
                 4   3   7   2   1
  </code></pre>
  
  <p>Gives the output:</p>
  
  <pre><code>outputVector = 
  
                 3.5000
  </code></pre>
  
  <p>I would like the same behaviour to be maintained regardless of how many rows are in the input. To clarify, the correct output for the second example above should be:</p>
  
  <pre><code>outputVector =
  
                 4   3
  </code></pre>