I am trying to run a controller in simulink, which is to be called by an external matlab script interfacing realtime with a physical system at a fixed sampling period. Since changing everything completely to matlab or completely to Simulink will require lots of code to be rewritten, I expected to use the model(t,x,u,'outputs'), model(t,x,u,'update') commands (as described here:http://www.mathworks.com/help/simulink/slref/model_cmd.html) to get the output of the controller and the updated state of the controller from simulink, then pass it on the external matlab script. However, the controller states do not get updated (they remain constant at their initial values). The computation is happening only for zero execution time, even though I provide an array of times in the 't' argument. Kindly help me understand how I can do this correctly. Using the 'sim' command doesn't seem like the right way to do this as it would restart the simulation on each call which is more time consuming, we just want to step the simulink controller through a fixed time step on each call, i.e., invoke its solver for a time step and maintain the updated state until the next call.