Which exponential option block: fcn vs math function, is more accurate in a Simulink model?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Albert Johan Mamani Larico
le 30 Déc 2024
Réponse apportée : Paul
le 30 Déc 2024
Hi all.
I have a vector 'p' of 388 values and 2 constant values (fc and b). I want to get '(p/fc)^b'
First I applied the fcn block (u/fc)^b where u=p. Also I applied the math pow block with a gain block as figure attached. When I compare both, the second option results are greater than the fcn block. Even the difference is small I would like to know which option is more accurate or recommended and if possible the reason of that small difference.

1 commentaire
Malay Agarwal
le 30 Déc 2024
I think both the methods should be roughly equal and the differences you are noticing are because of how floating-point operations work. Due to how floating-point operations work, there can be small differences in the results of the same operation when the operation is done multiple times.
The following resource has more details about how floating-point numbers behave: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html.
But I recommend comparing the output of both the methods with different external sources such as WolframAlpha to determine which method yields a more consistent result.
Réponse acceptée
Paul
le 30 Déc 2024
In general u/fc (top path), is not exactly the same as u*(1/fc) (bottom path) in floating point.
Example:
rng(100)
u = rand;
fc = rand;
isequal(u/fc,u*(1/fc))
u/fc - u*(1/fc)
Try making the top path in the fcn u*(1/fc) or (1/fc)*u and see if that matches the bottom. Alternatively, use the Divide block to divide u by fc in the bottom path (instead of the gain) to see if that matches the top.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur General Applications dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!