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

4 次查看(过去 30 天)
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.

回答(1 个)

kintali narendra
kintali narendra 2016-9-23
"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 个评论
Michael Palmer
Michael Palmer 2016-9-24
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by