How do I write to a variable multiple times in the same time step in simulink?
14 次查看(过去 30 天)
显示 更早的评论
I have a control loop in Simulink which writes to a variable multiple times using the DATA STORE WRITE block. I then read the most recent data value using the DATA STORE READ block. Finally, I use this value (signal) elsewhere in my program. How can I do this?
I am getting the following error:
The block 'Data Store Write2' is writing to the data store 'Data Store Memory' but the block(s) 'Data Store Read' have already read from a portion or the entire region of this memory at time 0.0. For performance reasons, occurrences of this diagnostic for this memory at other simulation time steps will be suppressed.
A simple block diagram of what I am trying to do is as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/155331/image.png)
0 个评论
采纳的回答
Fangjun Jiang
2016-8-1
This is a good case for using the Merge block. Connect all three outputs to a Merge block and then connect to a single "Data Store Write" block with the tag "rpm_cmd". Double click the Merge block, click the "Help" button to see the detailed explanation of the Merge block.
3 个评论
Fangjun Jiang
2016-8-2
Yes. it will. The output of two "If Action Subsystem" can be merged. The output of the "Add" block should not be connected to the Merge block. It doesn't make sense even if the Merge block doesn't give error. The whole subsystem is executed once every sample time. The execution order follows the data flow. The "Add" block is executed, then either the "If" action or the "Else" action. The Merge block always takes the latest update. So connecting the "Add" block to the "Merge" block has no effect even there is no error.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Event Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!