How to run simulink from matlab script, pause the simulation, change constant values, and continue the simulation

4 views (last 30 days)
Hi all, I want to run a simulation from a matlab script (or function) using workspace variables as parameter values for constant blocks in the simulation. I want to be able to pause the simulation at a specific time (say 10 seconds in) and change the value of the constant, then resume the simulation. Is there a way to do this. As a simple descriptive example, lets say I have a simulation which plots A*sin(wt) in a scope. 'A' and 'w' are constant blocks with values which are defined in the workspace with A=1 and w=1. At 1 second into the simulation, I want to pause it and change A=2, then continue the simulation. Is it possible to do this in a matlab script? If so, please let me know how.

Answers (1)

kintali narendra
kintali narendra on 23 Sep 2016
"sim" is the name of the function which can run the simulation from through programming. check the link below for more details
https://www.mathworks.com/help/simulink/ug/using-the-sim-command.html
  1 Comment
Michael Palmer
Michael Palmer on 24 Sep 2016
Thanks Kintali, I know about the "sim" command; however, I am unsure how to subsequently pause the simulation, change constant values (in the script), and resume. Do you know how this is accomplished?

Sign in to comment.

Categories

Find more on Simulink 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!