Set Simulink model simulation stop time from m file

325 views (last 30 days)
Lucas
Lucas on 6 Jun 2012
Answered: Bill Tubbs on 25 Nov 2021
I want to set my models simulation stop time from an m file, but I'm a little confused about how to go about it. When I'd get the data for blocks I'd use get_param, but I want to get the parameters of the model. Would I go about it the same way? Thanks.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 6 Jun 2012
You can set_param for the model also:
set_param('modelname', 'StopTime', '3000')
  3 Comments
Athira Km
Athira Km on 12 Aug 2021
Thank you but how to set this dynamically from a parameter instead of a constant value?

Sign in to comment.

More Answers (1)

Bill Tubbs
Bill Tubbs on 25 Nov 2021
You can also do it by passing it as an argument when you run the simulation from the m file:
sim_out = sim(sim_model, t_stop)

Community Treasure Hunt

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

Start Hunting!