while loop simulink running

4 views (last 30 days)
Michael Simonovski
Michael Simonovski on 11 May 2018
Hello,
i have a simulink model and i want to run it in a while loop. For example:
The simulink model itself should run 10 s, after this a value should increment (c=c+1) and it should run again 10 s. This should happen till a certainly value for example for c appear.
Is it possible to make in Simulink?
My aim:
I want to write a script. This script schould call a simulink model in a while loop, till a value appear.
During the run the matlab script should get in live time certainly values from a channel in simulink (not after the simulink run is finish)!
If the value differ from the set value, the simulation should be stopped, the parameter increment and the run should appear again.
If a error appears, which call a pop up window. The simulink model should stop and the parameter should be incremented again. The simulink should run after it and so on.
Is it possible to make such a script?
How it could look like?
Thanks in advance!

Answers (1)

Jim Riggs
Jim Riggs on 11 May 2018
for c=1:10
sim('SimulinkModelName')
end
This will run the specified Simulink model 10 times with c=1 to 10.

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!