MATLAB Answers

Is it possible to avoid division by zero errors in a Simulink model, such that the results from a simulation are stable when using Simulink 7.7 (R2011a) ?

437 views (last 30 days)
I am using a simple model in Simulink in which I use a Divide operation on two input values and further plot them. In course of simulation, there might be a ZERO value fed to the denominator of the DIVIDE block, forcing a division by zero warning/error message. This makes the simulation unstable.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 13 Mar 2012
In order to "solve" the divide by zero issue, there is only one good way.It is to make a model which does not feed 0 to a division block.
The workarounds are to:
1. Use a SWITCH block to pass EPS instead of 0 in the forward path to the DIVIDE block will also eliminate a divide by zero case.
2. Use a MATLAB Fcn block to implement
This is demonstrated in the attached model 'example_no_divide_by_zeroFcn'

Sign in to comment.

More Answers (2)

Ajith Tom George
Ajith Tom George on 2 Oct 2017
Instead of using a Matlab function block, the "Fcn" block, which is also available in the list of User-defined functions, would be better. Inside it implement the same logic:
Using Fcn block is better because it works without any additional compiler requirement.

Shivaprasad G V
Shivaprasad G V on 6 Mar 2019
this would be helpful to avoid the 0/0 or n/0 situation. this below block prevents the formation of indeterminent form. hope this will be helpful. thank you. zero.PNG


No tags entered yet.




Community Treasure Hunt

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

Start Hunting!