Why are the simulation results different when using "Data Store" blocks instead of directly connected blocks and which result is the correct one?

Hi all,
my problem is that when I'm comparing two apparently similar models with each other I get different simulation results. One model uses Data Store blocks (read, write and memory) and the other model is "hard wired". All other blocks remain the same and that is why I also expected the results to be the same or at least come close to each other.
I tried and used different solvers with different step sizes and also varied the function input parameters which also changed the outcome - with some settings the results come close to each other but with others they do not at all.
So why do the results differ from each other and how do I solve this problem?
Thx for your help, Michael

 Accepted Answer

Hi Michael,
Data Stores break up the sorting order. If you have e.g.
-> GainA -> GainB ->
you know, that GainA executes before GainB. But if you break up this line by data stores
-> GainA -> DataStoreWrite
and
DataStoreRead -> GainB
Simulink has the freedom to either compute the GainA->DataStoreWrite first or the DataStoreRead->GainB. Of course the latter would give different results (namely shifted by one time step).
I suggest to display the sorting order: menu Display->Blocks->Display Sorted Order to find out if this the case for your model.
Titus

1 Comment

Hi Titus,
I just checked the execution order and it is (according to the numbers) the same in both models. I've also simulated the model with the option "Sorted Execution Order" enabled but the outcome is still a difference between both models.
Michael

Sign in to comment.

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!