title: Simulink: compute signal derivative inside MATLAB function block without extra blocks?
body: <p>I am feeding a signal <code>q</code> into a MATLAB Function block - for example a sinusoid (it could be something else too). My MATLAB Function block also needs the time derivative of the signal. In Simulink I can do something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/hqzKd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hqzKd.png" alt="enter image description here"></a></p>
  
  <p>However I'd like to forego the Derivative block (to conserve space, my actual model is much bigger than the above) and somehow get the derivative directly inside the MATLAB Function. For this I'd need to know the previous value of <code>q</code> probably... which I can't know without adding a memory block.</p>
  
  <p><strong>Question</strong> : How do I get <code>qdot</code> inside MATLAB Function without using any extra blocks (and removing the Derivative block above obviously)?</p>
  
  <p>Thanks for your help!</p>