Which exponential option block: fcn vs math function, is more accurate in a Simulink model?
29 views (last 30 days)
Show older comments
Albert Johan Mamani Larico
on 30 Dec 2024 at 14:00
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 Comment
Malay Agarwal
on 30 Dec 2024 at 14:22
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.
Accepted Answer
Paul
on 30 Dec 2024 at 14:58
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 Comments
More Answers (0)
See Also
Categories
Find more on Array and Matrix Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!