What is the proper use of programmatic simulink interface : model(t,x,u,flag)? Can I use it to step forward through a simulation while synchronising it with an external matlab script progress.

3 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Archit Dhanani
Archit Dhanani el 29 de Jul. de 2019

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by