Run Simulink iteration by iteration in MATLAB script
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Katrine G. Andersen
am 13 Nov. 2015
Kommentiert: Katrine G. Andersen
am 14 Nov. 2015
I have a Simulink model and a MATLAB script. I am collecting data from the Simulink model into the MATLAB script, meaning that I need to run the Simulink model iteration by iteration, because I need the data from my Simulink model in my MATLAB script. I have googled, and found one answer saying to write the following in my script:
sim('name_of_model', [tStart tFinal]);
but this only runs the model from 0 to x seconds, and not iteration by iteration. Can anyone please help me?
0 Kommentare
Akzeptierte Antwort
Sebastian Castro
am 13 Nov. 2015
When you run a Simulink model from the command-line, it always runs the whole thing. There are some pause/continue controls, but that's not the way to go because you don't really have control over how many time steps run before you pause the model.
I would recommend taking the code in your MATLAB script and placing it into a MATLAB Function block. Then, your model can use that code at every time step as it runs, and can seamlessly accept/return data to/from the rest of the model.
- Sebastian
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!