title: How can I speed up this loop?
body: <p>I have a huge matrix (5000x5000x100) and I'm trying to smooth each index along the third dimension, but it takes HOURS. I am doing something inefficiently. </p>
  
  <pre><code>new_mat=zeros(size(my_mat));
  for i = 1:length(mymat)
     for j = 1:length(mymat)
        new_mat(i,j,:) = wdenoise(squeeze(mymat(i,j,:)));
     end
  end
  </code></pre>
  
  <p>I know arrays and indexing would help but I'm not sure how to apply them here. Thanks for any help.</p>