Simulink "Sum" block giving wrong result

I ran a simulation that produced an unnexpected result. It was supposed to be just a noise floor, but for some periods this signal seems to stay constane and then spike before returning to normal. And it happened twice in this particular length of simulation:
I tried the debugger and found an error in a sum block. I've tried re-running multiple times, the error occurs at the same timestep (my noise input didn't change between these runs). If I change the tolerance, it still occurs, but at a different time step.
Example, in this step, the result of the sum of this two signals is correct 1.9794e-11 - 1.905161e-11 = 7.43e-13;
As well as in the next step, -9.639417e-13 + 3.0406e-12 = 2.07e-12
however, at the next step, the signals are updated, but the sum, wrongly, still displays the previous value:
It continues for several steps. If I choose to run the remaining of the simulation, eventually it just "explodes" after a while and goes back to normal.
What could be going on?

3 件のコメント

Youssef Noureddine
Youssef Noureddine 2022 年 11 月 9 日
Hi Arthur,
Can you log the value of the three signals that go into the add block and save it to a .MAT file and attach it here so that I can take a look at it and try it on my end? I can take a look at it tomorrow, but having the signal value history will greatly assist me in determining what could be causing what you are encountering.
Sincerely,
Youssef
Arthur Reis
Arthur Reis 2022 年 11 月 14 日
Sure thing.
If I import them into matlab and try to sum them, the result is different from what simulink has calculated.
input1 = load('input1.mat').data;
input2 = load('input2.mat').data;
input3 = load('input3.mat').data;
output_from_add = load('output_from_add.mat').data;
input3.Data %input3 is a constant 0;
ans = 0
sumofinputs = input1 + input2;
df = sumofinputs - output_from_add;
plot(df);
Arthur Reis
Arthur Reis 2022 年 11 月 14 日
編集済み: Arthur Reis 2022 年 11 月 14 日
~~Just an update: selecting ode113 as a solver seems to solve this problem (ode45 is the problematic). And I haven't tried the others.~~
~~So, this could be related to the solver selection. Any insights of why?~~
Edit: Ignore the previous lines... it just changed the timestep where the error occurs

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 11 月 3 日

編集済み:

2022 年 11 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by