Why the results are different when just two signals get swapped over at the adder

1 回表示 (過去 30 日間)
TeraWatt
TeraWatt 2023 年 10 月 9 日
回答済み: vidyesh 2023 年 10 月 11 日
I have attached my simulink file of my isssue.
I was implementing an IIF block and noticed that my results change if i swape over two signals at the adder. These two signals are the feedback signals multiply by teh filter coefficients. The picture below shows the add and the two signals above mentioned.
here is a zoom of the plot which shows the difference between both model (red and blue)
Also I have changed the "product" block for this signals and use GAINS instead, the result slightlychanged but still there is an efect on the output linked to the position of the two feedback signals at the adder.
Why Does this happend?
Your comments will be apprecitated

回答 (1 件)

vidyesh
vidyesh 2023 年 10 月 11 日
Hi TeraWatt,
I understand that you would like to know why the outputs of a subtractor differs when the inputs are swapped.
The reason for this discrepancy lies in the data type of your signals, which is set to 'single'. In MATLAB, 'single' data type represents 32-bit floating-point values. Floating-point numbers have finite precision, making computations involving them prone to limited accuracy, particularly in calculations requiring exact values or high precision.
To address this, you can change the data type to 'double' in MATLAB. It offers increased precision compared to 'single', reducing differences in subtractor outputs when inputs are swapped.
Another way to minimize floating point error is to combine "large" and "small" numbers separately when possible. For example, instead of (large-small)-small it would be better to instead do large-(small+small).
For more detailed information on floating-point numbers and their limitations, you can refer to the following documentation:
I hope this answer helps.

カテゴリ

Help Center および File ExchangeNaming Conventions についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by