Effacer les filtres
Effacer les filtres

Simulink Block Warning of logaritmic function

2 vues (au cours des 30 derniers jours)
dilara ayyildiz
dilara ayyildiz le 18 Oct 2021
Réponse apportée : Sameer le 24 Avr 2024
I'm trying modelling of my logaritmic function and i've got keep taking this warning.
Log of zero in 'untitled1/Log10'

Réponses (1)

Sameer
Sameer le 24 Avr 2024
Hi Dilara
The warning "Log of zero in 'untitled1/Log10'" in Simulink indicates an attempt to compute the logarithm of zero, which is mathematically undefined. Logarithmic functions, including both natural logarithm (ln, base (e)) and common logarithm (log, base 10), are undefined at zero, leading to potential errors or unexpected behavior in simulations.
To address this issue, several approaches can be considered:
1. Adding an Offset
One can add a small offset to the input of the logarithm block to ensure it never reaches zero. For instance, if using a Log10 block, instead of feeding it directly with (x), one can feed it (x + epsilon) where (epsilon) is a small constant like (1e-6) or (1e-9). This method prevents the input from being zero or negative.
2. Utilizing a Conditional Statement or Switch Block
Implementing a condition to check the input value before it reaches the logarithm block can be effective. If the value is less than or equal to a certain threshold, the flow can be redirected to avoid taking the logarithm of a non-positive number. This can be achieved using a Switch block or a MATLAB Function block with an if statement.
3. Implementing a Saturation Block
A Saturation block can be used to limit the input value to the logarithm block to remain above a certain minimum value. Setting the lower limit of the Saturation block to a small positive number (like (1e-6)) and the upper limit to Inf or another appropriate value can ensure safe operation.
4. Creating a Custom MATLAB Function Block
For more complex requirements, a MATLAB Function block can offer a flexible solution, allowing for sophisticated logic to handle values around zero. For example, it can return a special value or perform a different calculation when the input is near zero.
By adopting one of these solutions according to your requirement, the "Log of zero" warning in Simulink models can be effectively resolved, ensuring accurate and reliable simulation results.
I hope this helps!
Sameer

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by