How can I access to the Model Workspace from my Simulink file from a Matlab function block
16 views (last 30 days)
I have created a function in a .m file which is used in a Matlab Function Block inside a Simulink model. There is a parameter that the .m function uses which is created in the Model Workspace, since it is impossible to connect that variable to a constant block, how can I access to the Model Workspace to extract the variable I want for my .m function?
Fangjun Jiang on 6 Jun 2022
In the MATLAB Function block, click "edit data", add a data "MyVar", specify it as a "parameter" of the MATLAB Function block.
In the Simulink model's "Model Workspace", make sure there is a variable called "MyVar", then you are all set.
For a Simulink model parameter, it always looks for it first in the "Model Workspae" and then the "base workspace".