simulink preventing signal below 0
37 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Andreas Goser
on 17 Jan 2014
Edited: Andreas Goser
on 17 Jan 2014
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 Comments
Haiko
on 17 Jan 2014
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.
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!