How to update variable in Workspace during simulation?

조회 수: 14 (최근 30일)
rach
rach 2012년 5월 29일
댓글: tq yu 2019년 5월 15일
Hi all,
I have a simulink simulation that runs for 20s. At every 5s, it will generate a new set of data, which needs to be written to the workspace automatically. (Hence, the values in workspace should be updated automatically every 5s).
Right now, even though I try to write to the workspace every 5s, the values in the workspace remain at its initial value throughout the simulation and only update at the very end of the entire simulation time (i.e. after 20s).
May I know what should I do? Any advice or help is really greatly appreciated!
Best Regards, Rachel

답변 (2개)

Kaustubha Govind
Kaustubha Govind 2012년 5월 29일
I'm assuming that you are using something like the To Workspace block to write data to the workspace? I explained a little in my second paragraph over here, why I think that operation is not guaranteed to be completed until the end of simulation.
However, it seems (from your comment to the cyclist's answer) the broader issue is that you are attempting to update a block parameter based on a signal. Read this blog post to understand why that cannot be done.
  댓글 수: 2
rach
rach 2012년 5월 29일
Hi Govind,
Thanks for the answer. Just a quick question, is there any matlab command that does the exact opposite as 'assignin', just that instead of assigning values to workspace variables, it reads variables out from the workspace?
Thank you so much for your time.
TAB
TAB 2012년 5월 30일
To read the value from specific workspace used "evalin" command.
See
>> doc evalin

댓글을 달려면 로그인하십시오.


the cyclist
the cyclist 2012년 5월 29일
I am not familiar with simulink, but will the assignin() command solve your problem?
>> doc assignin
  댓글 수: 3
Homer Lan
Homer Lan 2018년 2월 8일
Hi, I met the same question with u. I want to update the value in the workspace when the simulink was running. And I use 'assignin',the value in the workspace can only save the initial value. And it cannot change with the simulation starting. How can I solve this? Thank you for your help!
tq yu
tq yu 2019년 5월 15일
Hi , Lan ,have you solved your problem ?I have the datas in workspace that are time-updating ,how can i sen these datas to simulink models to achive rea-time simulation?Thks a lot

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by