title: How to repeat a vector along a diagonal in Matlab
body: <p>I would like to repeat a vector <code>A</code> of length <code>n</code> on a diagonal <code>m</code> times to obtain a <code>(n+m-1) x m</code> matrix <code>B</code>. As an example let's say <code>A = [a;b;c;d]</code>, <code>m = 4</code>. This should result in</p>
  
  <pre><code>B = 
  [a 0 0 0;
   b a 0 0;
   c b a 0;
   d c b a;
   0 d c b;
   0 0 d c;
   0 0 0 d]
  </code></pre>
  
  <p>Any suggestions for a fast way to achieve this? <code>blkdiag(repmat(A,1,m))</code> does not help me in this case as it creates a <code>(n*m) x m</code> matrix.</p>
  
  <p>In the end I am actually just interested in the matrix product <code>D</code> of a third matrix <code>C</code> with <code>B</code>:</p>
  
  <pre><code>D=C*B
  </code></pre>
  
  <p>If you see another option to obtain <code>D</code> without having to generate <code>B</code>, I would appreciate it. But a solution for the problem above would make me very happy as well! <code>n</code> and <code>m</code> will be quite big by the way.</p>
  
  <p>Thanks!</p>