simulink preventing signal below 0

58 次查看(过去 30 天)
Tom
Tom 2014-1-17
Hi,
I have a model which runs fast but the problem is that simulink takes to big time steps and by this the signal goes below zero. My model has exponential functions and thus will never go below zero. But because a too big time step close to 0 the signal jumps below zero and I get errors of derivative inputs being infinite. Is there a way to prevent simulink from getting values below 0 because due to the model this could normally not happen. I still want simulink to calculate fast (thus changing the absolute/relative error margins is not advisable because this seems to work but the simulation time for the values which are far from 0 takes 50 times longer) but only if he sees that it becomes zero that he goes back to the past and take smaller time steps. It is also not zero crossing because he will search for a value which he will never be able to find. Can somebody help me with this problem?
Tom Wambecq

回答(2 个)

Andreas Goser
Andreas Goser 2014-1-17
编辑:Andreas Goser 2014-1-17
OK, you seem to be aware of the numerical risks of addressing this issue not by solver settings...
In this case I suggest the block "Saturation" and set the lower limit to 0 and the upper limit to a reasonable value you will not reach anyway or inf.
  2 个评论
Tom
Tom 2014-1-17
Hi,
this would change the value and not force simulink to step back in time when he sees a negative value and take at that point smaller values. Are there other options?
Tom Wambecq
Andreas Goser
Andreas Goser 2014-1-17
I would say "You can't eat the cake and have it".

请先登录,再进行评论。


Haiko
Haiko 2014-1-17
A simple possibility is to add a few blocks to your system.
For example a switch block. Using the normal input when larger than zero and z zero input when smaller than zero.
Anonther easy solution would be an if block and subsystems.
Something like this:
if (u1 > 0) {
body_1;
}
elseif (u1 < 0){
body_2; % with in the subblock a gain of zero
}
else {
body_3;
}
Anonther easy solution would be a switch block. Using the normal input when larger than zero and z zero input when smaller than zero.
  1 个评论
Tom
Tom 2014-1-17
Hi,
this is also adjusting the signal after it has been calculated while I want simulink to step back and take smaller steps to avoid the negative values. It is all good solutions but unfortunately not applicable in my situation. Thanks already for the examples and solutions. If you have more options to somehow force the solver to do different things: feel free to tell me.
Tom Wambecq

请先登录,再进行评论。

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by