Control Simulibk step size through an internal coondition

조회 수: 2 (최근 30일)
Anfänger
Anfänger 2014년 8월 11일
댓글: Anfänger 2014년 8월 12일
I have implemented some blocks (S-Function level-2 using Matlab code, matlab function block...etc) in simulink, and I have an internal stability condition which will determine the step size after each simulation step. I know that I can set the solver to a variable step solver, but how can I make simulink check for the different obtained step sizes, and then, impose the smallest to all blocks? For the time being , I am using the following trick:
set_param(bdroot,'MaxStep',num2str(dT));
set_param(bdroot,'MinStep',num2str(dT*0.9999));
because the minimum and maximum steps cannot be the same. However, this is not working good enough.

답변 (1개)

Christopher Berry
Christopher Berry 2014년 8월 11일
Anfanger,
In order for the parameters MinStep and MaxStep to be enabled, the solver Type must be VariableStep. If you are using a fixed step solver, then these settings will just be ignored. So make sure you are using a variable-step solver, like ode45.
Also, I have no problems setting the MinStep and MaxStep to the same values, what error are you getting when you do:
set_param(bdroot,'MaxStep',num2str(dT));
set_param(bdroot,'MinStep',num2str(dT));
Other than that, this method seems like it should work, so what about it specifically is not good enough?
  댓글 수: 1
Anfänger
Anfänger 2014년 8월 12일
hi Christopher,
Thanks for the answer. However, I did use a variable step solver. The thing is that I am solving Partial differential Equations by myself, and hence, I have my stability condition on the time step. I then created a library, so each block can be used more then once. Since, each block will have a different set of inputs, the obtained time steps (for one iteration, from different blocks) will be different. Is there a way to force simulink automatically to compare and take the smallest one?

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by