Which exponential option block: fcn vs math function, is more accurate in a Simulink model?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Albert Johan Mamani Larico
am 30 Dez. 2024
Beantwortet: Paul
am 30 Dez. 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 Kommentar
Malay Agarwal
am 30 Dez. 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.
Akzeptierte Antwort
Paul
am 30 Dez. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Array and Matrix Mathematics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!