Can step size be changed during a Simulink simulation?

조회 수: 15 (최근 30일)
Gerardo Malavena
Gerardo Malavena 2018년 9월 13일
답변: Rishabh Gupta 2018년 9월 24일
Hi, I need to change the maximum step size in the middle of a Simulink simulation. My idea was the following:
set_param(bdroot,'FixedStep', num2str(InitialStepSize));
set_param(bdroot,'SimulationCommand','start');
% pause the simulation at a certain t by means of an _assertion block_
set_param(bdroot,'FixedStep', num2str(NewStepSize));
set_param(bdroot,'SimulationCommand','continue');
By doing so I get an error saying that the step size cannot be changed while the simulation is running. Is there any way to do this? A workaround would be to split the simulation in two parts. Simulate the first part with InitialStepSize, stop the simulation at t, save the status, and simulating with NewStepSize starting from the previously saved state. Anyway, I do not like such a solution that much.
Thank you

답변 (1개)

Rishabh Gupta
Rishabh Gupta 2018년 9월 24일
Hi Gerardo,
Changing the step Size during the Simulation is not possible. There could be another workaround, but it would depend on your exact use case if it would be feasible to use that or not.
You could simulate the model at a step size as follows:
step_size = HCF (step_size_of_first_part_of_model , step_size_of_second_part_of_model).
For example :
If you want step size = 4 for first part of model and step size = 5 for second part of the model then you could simulate the model at step size = HCF(4,5) = 1.
Then you would need to manually look at the output and process it to get the model output at desired time stamps.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by