How do I get the relative error between 2 signals in Simulink?

8 vues (au cours des 30 derniers jours)
Jadon
Jadon le 12 Fév 2025
Modifié(e) : Fangjun Jiang le 12 Fév 2025

I have two first order transfer functions in Simulink. One is the exact system and the other is a close approximation. How would I get the relative error between the two? I tried using an addition block to subtract the exact function from the approximation and then taking the output from the addition block and using a divide block to divide the absolute error by the output of the original transfer function to get the relative error. The addition block looks to be giving the correct absolute error, but then the divide block sends out a massive maximum relative error value, on the order of 10^23.

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 12 Fév 2025
Modifié(e) : Fangjun Jiang le 12 Fév 2025
Assume x and y are the two signals, you are doing
abs((x-y)/x) or abs((x-y)/y), when x or y is close to zero, it will cause divided-by-zero error, or cause the result to be very large which does not represent the true relative error.
  1 commentaire
Jadon
Jadon le 12 Fév 2025

That's what I figured, but is there a good way to handle that or a different way to find the error?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by