Phab
Phab

Reputation: 495

(Simulink) Write Data only on change

I have the following problem:

Matlab/Simulink gives me the warning:

Warning: The block 'Data Store Write1' is writing to the data store 'Data Store' but the block(s) 'Data Store Write2' have already written to a portion or the entire region of this memory at time t

This is because of my model looking like this:

enter image description here

Inside the Stateflow chart the code is:

[hasChanged(In)] {Out = In;}

So my question is: Is there an option or something else the Data Store Write blocks are write only on change?

Annotations:

Upvotes: 0

Views: 2240

Answers (1)

Phab
Phab

Reputation: 495

The most satisfying solution I found, was to build an own 'write-only-on-change" block and add it to the library:

These three pictures show the structure of the block from outer to inner:

enter image description here

enter image description here

enter image description here

The subsystem is triggered on rising signals from the change detection block. Also I added a mask to specify where to save the signal (data store/bus name).

enter image description here

Upvotes: 1

Related Questions