title: image stack display in matlab using a slider
body: <p>I have a 3 dimension matrix of data (a stack of images across a dimension, time for example.
  I want to display an image, and have a slider below to navigate across the images.</p>
  
  <p>I wrote a piece of code which works, but it's bulky and kinda ugly I think...I want to write a clean function and so I would like to know if anyone know of a cleaner, nicer way to do it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>interv = [min max]; % interval for image visualization
  
  imagesc(Temps_visu,X*100,squeeze(X,Y,MyMatrix(:,:,1)),interv);
  
  title('My Title');
  xlabel('X (cm)');
  ylabel('Y (cm)');
  
  pos = get(gca,'position');
  % slider position
  Newpos = [pos(1) pos(2)-0.1 pos(3) 0.05];
  
  pp = 1;
  % callback slider
  S = ['pp=floor(get(gcbo,''value''));imagesc(Temps_visu,X*100,squeeze(X,Y,MyMatrix(:,:,1)),interv));' ...
      'set_axes_elasto;title(''My Title'');disp(pp);'];
  
  Mz = size(MyMatrix,3);
  
  % Creating Uicontrol
  h = uicontrol('style','slider',...
      'units','normalized',...
      'position',Newpos,...
      'callback',S,...
      'min',1,'max',Mz,...
      'value',pp,...
      'sliderstep',[1/(Mz-1) 10/(Mz-1)]);
  </code></pre>