Clear Filters
Clear Filters

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

2 views (last 30 days)
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

Answers (1)

vidyesh
vidyesh on 11 Oct 2023
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.

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!