title: Duplicating a 2d matrix in matlab along a 3rd axis MANY times
body: <p>I'm looking to duplication a 784x784 matrix in matlab along a 3rd axis. The following code seems to work:</p>
  
  <pre><code>mat = reshape(repmat(mat, 1,10000),784,784,10000);
  </code></pre>
  
  <p>Unfortunately, it takes so long to run it's worthless (changing the 10,000s to 1000 makes it take a few minutes, and using 10,000 makes my whole machine freeze up practically). is there a faster way to do this?</p>
  
  <p>For reference, I'm looking to use mvnpdf on 10,000 vectors each of length 784, using the same covariance matrix for each. So my final call looks like</p>
  
  <pre><code>mvnpdf(X,mu,mat)  
  
  %size(X) = (10000,784), size(mu) = (10000,784), size(mat) = 784,784,10000
  </code></pre>
  
  <p>If there's a way to do this that's not repeating the covariance matrix 10,000 times, that'd be helpful too. Thanks!</p>