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년 7월 30일
편집: Walter Roberson 2022년 7월 31일
It looks to me as if PostLoadFcn callback might be the appropriate place to initialize the contents of the global variables the first time. I suspect that you are possibly using InitFcn callback at the moment
Daniel Harman
Daniel Harman 2022년 7월 31일
Unfortunately, I can't find that callback on the Data Store list of callbacks.
You would attach it to the model itself. Load the model, have the model PostLoadFcn callback set the initial values for the Data Store
First, please clarify "run i", "run i+1" is "runs one time" or "runs one time step"? "i+1" is the next simulation run, or the next simulation time step?
next simulation run is my understanding
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일

0 개 추천

"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'))
or

댓글 수: 1

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개)

카테고리

제품

릴리스

R2022a

질문:

2022년 7월 30일

댓글:

2022년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by