title: Why would an interpreted MATLAB function block be evaluated twice in Simulink?
body: <p>I have a Simulink model that includes the following subsystem.</p>
  
  <p><img src="https://i.stack.imgur.com/lag4a.png" alt="Simulink subsystem with interpreted MATLAB function"></p>
  
  <p>The <code>bm_train_adapter</code> block will call a MATLAB function of the same name, passing all the input arguments in a single vector.</p>
  
  <p>The subsystem has been given a sample time of 900 (secs), which is why all the signals are colored in red (for discrete signals).</p>
  
  <p>However, in the debugger I have observed that the <code>bm_train_adapter</code> function gets called twice at each simulation timestep. This yields horribly wrong results since the function includes side-effects.</p>
  
  <p><strong>Why is Simulink calling my interpreted MATLAB function more than once per timestep? How can I prevent this?</strong></p>