title: MATLAB: GUI progressively getting slower
body: <p>I've been programming some MATLAB GUIs (<strong>not using GUIDE</strong>), mainly for viewing images and some other simple operations (such as selecting points and plotting some data from the images). </p>
  
  <p>When the GUI starts, all the operations are performed quickly.
  However, as the GUI is used (showing different frames from 3D/4D volumes and perfoming the operations mentioned above), it starts getting progressively slower, reaching a point where it is too slow for common usage.</p>
  
  <p>I would like to hear some input regarding:</p>
  
  <ul>
  <li>Possible strategies to find out <strong>why</strong> the GUI is getting slower;</li>
  <li>Good MATLAB GUI programming practices to avoid this;</li>
  <li>Possible references that address these issues.</li>
  </ul>
  
  <p>I'm using set/getappdata to save variables in the main figure of the GUI and communicate between functions.</p>
  
  <p><em>(I wish I could provide a minimal working example, but I don't think it is suitable in this case because this only happens in somewhat more complex GUIs.)</em></p>
  
  <p>Thanks a lot.</p>
  
  <p><strong><em>EDIT:</em></strong> <em>(Reporting back some findings using the profiler:)</em></p>
  
  <p>I used the profiler in two occasions: </p>
  
  <ul>
  <li>immediatly after starting the GUI;</li>
  <li>after playing around with it for some time, until it started getting too slow.</li>
  </ul>
  
  <p>I performed the exact same procedure in both profiling operations, which was simply moving the mouse around the GUI (<strong>same "path" both times</strong>).</p>
  
  <p>The profiler results are as follows:</p>
  
  <p><img src="https://i.stack.imgur.com/WYM7N.png" alt="enter image description here"></p>
  
  <p>I am having difficulties in interpreting these results...
  Why is the number of calls of certain functions (such as <code>impixelinfo</code>) so bigger in the second case? </p>
  
  <p>Any opinions? </p>
  
  <p>Thanks a lot.</p>