How can i pass variables from an m file from the function workspace to the base workspace
8 ビュー (過去 30 日間)
古いコメントを表示
Hello, I´m writing a GUI code to run a simulink model with a push button.
In order to run the model, I have to run an .m file. The .m file is a script that creates more than 50 variables.
I want the GUI to run the .m file and save the variables in the base workspace, so the simulink model can run properly.
Is this posible? I've been reading a lot of questions but i couldn't find an answer.
Thanks.
Pedro
0 件のコメント
回答 (2 件)
Azzi Abdelmalek
2013 年 10 月 11 日
If your simulink model name is untitled, you can set the InitFcn of your model to mfile (mfile is the m-file that provide your 50 variables)
set_param('untitled','InitFcn','mfile')
0 件のコメント
cr
2013 年 10 月 12 日
In general, if you need to access base workspace while inside a function, you can use evalin. evalin('base','scriptfile'). If this were done inside a callback, scriptfile would create the variables in base workspace.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Model, Block, and Port Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!