How to permanently store Base Workspace variables with Simulink file?

조회 수: 5 (최근 30일)
Kenny
Kenny 2014년 3월 3일
댓글: Kenny 2014년 3월 3일
Hi all!
I have loaded other people's simulink .MDL files into matlab, and I notice that some new Base Workspace variables become created once the .mdl file has been loaded.
I am extremely interested to learn how to embed BASE Workspace variables within simulink .mdl files.
At the moment, I know how to ADD Base Workspace variables using the Model Explorer (within the simulink system). However, the problem is....when I save the simulink file, those Base Workspace quantities (that I added) do not get saved.
I've been trying to figure out how those people embed those base workspace variables within their simulink files, but haven't figured it out yet. So I thought I'd finally ask how to do this on the forums.
Thanks very much in advance for any help.

채택된 답변

Suneesh
Suneesh 2014년 3월 3일
This is usually done using model callbacks. See:
Using one of the model callbacks like "PostLoadFcn" you may either execute a LOAD statement which loads a MAT file containing all your variables or have a MATLAB script which creates the workspace variables.
  댓글 수: 1
Kenny
Kenny 2014년 3월 3일
Hi Suneesh! Thank you very very much for your help and time. That was just what I needed. I was looking around for a long time to try work out how to embed the base workspace variables into the simulink mdl file. Thanks for showing me.
After reading that link you gave, it directed me to go to File -> Model Properties -> Callbacks.
Then, in the 'model pre-load function:' text box, I added for example .... value1=4;value2=50000;
Thanks again Suneesh. Much appreciated.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by