Which exponential option block: fcn vs math function, is more accurate in a Simulink model?
29 次查看(过去 30 天)
显示 更早的评论
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 个评论
Malay Agarwal
2024-12-30,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.
采纳的回答
Paul
2024-12-30,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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Array and Matrix Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!