I currently have a system that is partitioned into three files.
mySystem.msetSystemParameters.mmySystemModel.slx
I run mySystem.m from the command line
>> mySystem
which runs setSystemParameters.m and then launches the simulink model.
135 ...136 tend = 0.011;137 setSystemParameters;138 ...139 set_param('mySystemModel','StartTime', '0.0096', 'StopTime',string(tend))140 sim('mySystemModel');141 % start post processing
142 ...
this all runs fine and the workspace shows all the variable and parametric values and they are passed to the simulink model without issue.
I then created a GUI so the user can select system frequency from a set of radio buttons and a RUN PushButton to run mySystem.m after the desired frequency is selected. The frequency is being passed to mySystem.m properly and the mySystem.m runs when 'RUN' is pressed.
The problem is that the variables no longer apear in the workspace and the simulink nolonger has visibility to the values set in the mySystem.m and setSystemParameters.m files. I get a series of errors similar to:
Error using mySystem (line 140) Invalid setting in 'mySystemModel/Constant' for parameter 'Value'. Error using mySystem (line 140) Error evaluating parameter 'Value' in 'mySystemModel/Constant' Error using mySystem (line 140) Undefined function or variable 'DCin'.
'Constant' is a simulink library element with parameter 'Vaule' which is set in setSyetemParameters.m to DC in.
How do I maintain workspace and simulink visibility to the parameters after I launch the mySystem From the GUI?
Best Answer