title: how to rotate a 3D Matrix in matlab
body: <p>I have a 3D matrix with the dimensions X:24, Y:24, and Z:61397. Z corresponds to the number of frames. when I plot each frame I get an image that is rotated 45 degree clockwise.
  <a href="https://i.stack.imgur.com/Ld0dJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ld0dJ.jpg" alt="enter image description here"></a></p>
  
  <p>I've been trying to rotate the matrix so that the pictures can be straight.(It needs to be rotated 45 degree anticlockwise).</p>
  
  <p>I've tried multiplication by the following rotation matrix based on previous answers for similar question:</p>
  
  <pre><code>% rotation matrix 
  theta = pi/4;
  Rot = makehgtform('xrotate',theta);
  Rot = Rot(1:3,1:3);
  </code></pre>
  
  <p>I got an error due to the difference in size. Do I need to extend the rotation matrix to 24by24? If yes, how?</p>