title: How can I go through the columns of a matrix in matlab and add them each to a specific column of a sum matrix in matlab?
body: <p>Supose there is a Matrix</p>
  
  <pre><code>A =
  
   1     3     2    4
   4     2     5    8
   6     1     4    9
  </code></pre>
  
  <p>and I have a Vector containing the "class" of each column of this matrix for example</p>
  
  <pre><code>v = [1 , 1 , 2 , 3]
  </code></pre>
  
  <p>How can I sum the columns of the matrix to a new matrix as column vectors each to the column of their class? In this example columns 1 and 2 of A would added to the first column of the new matrix, column 2 to the 3 to the 2nd, column 4 the the 3rd.</p>
  
  <p>Like </p>
  
  <pre><code>SUM =
  
  4    2    4
  6    5    8
  7    4    9
  </code></pre>
  
  <p>Is this possible without loops?</p>