Simulink "globals" not working as expected

1 回表示 (過去 30 日間)
Daniel Harman
Daniel Harman 2022 年 7 月 30 日
コメント済み: Daniel Harman 2022 年 8 月 4 日
I have an open loop simulink model. It runs one time step and stops. I would like some of the intermediate data for run i to be available in run i+1. I have tried to use Data Stores. I write the intermediate data to them on run i and then have a read on i+1 that tries to use them. All that happens is it passes back the initialzed value each time. Is there a way to use Data Stores as I am attempting to use? If not, can you suggest an alternative? Thanks!
  6 件のコメント
Walter Roberson
Walter Roberson 2022 年 8 月 1 日
next simulation run is my understanding
Daniel Harman
Daniel Harman 2022 年 8 月 1 日
Next simulation run. I don't bring simulik down between runs. To give more context to what i'm attempting to do, an external program passes data to my simulink model and it runs for one time step and passes data back to that external program and stops processing until the external program passes data again. My simulink models the dynamics and I need to keep the previous dynamics state in order to calculate the next one once the external function passes data over again. I tried what was suggested and I'm still not getting the data saved. I'm enclosing some pictures of my blocks, which might point toward what I'm doing wrong. Thank you very much for your help so far!



Fangjun Jiang
Fangjun Jiang 2022 年 8 月 1 日
"global" data store is not meant for saving data between different simulation runs.
Refer to this:
web(fullfile(docroot, 'simulink/ug/decide-how-to-save-block-states-and-simulation-operating-points.html?s_tid=doc_srchtitle'))
  1 件のコメント
Daniel Harman
Daniel Harman 2022 年 8 月 4 日
The above link helped. I can initialize the functions using the "out" structure from a simulink run. Ultimately my problem was the intialization being incapable of using logic (if ~exist(out) use_initial_values else use_out end). Instead, I had to initialize "out" before running simulink and the initization feature had no problem. The first time run it would grab the initial run values. The next time, it would grab the last output simulink vectors. Simulink is a particularly finiky and frustrating system to use. Everything might be intuitive after a year of using it.


その他の回答 (0 件)


Help Center および File ExchangeEvent Functions についてさらに検索




Community Treasure Hunt

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

Start Hunting!

Translated by