Simulink 'To Workspace' Block variable change in a Matlab script

4 次查看(过去 30 天)
Hello, I have a Simulink model that is dependent on a parameter. Now I would like to change this parameter in a "loop function" and record a new data series in the workspace for each run. The problem is in the "to Workspace" block I cannot overwrite the variable via matlab script. Is there a command for this or another way of how I record data series to which a variable is assigned during the "loop function"?
Thank you in advance, Jan

回答(1 个)

Rhea Chandy
Rhea Chandy 2021-3-4
Hi Jan,
From what I understand, you need to find a way to change a variable parameter in a simulink model programmatically, but you're not able to overwrite the variable.
It may be that when you use the "To Workspace" block, the variable parameter is being saved into the model workspace rather than in the base workspace. This may be the reason you're not able to overwrite the variable via matlab script. More data about working with Model Workpaces is here: Model Workspaces
Another reason could be that If you are using the sim MATLAB function, the To Workspace block sends data to the workspace of the calling function, not to the MATLAB base workspace. The base workspace stores variables that are written at the command line. More info on the difference between the workspaces and how to share data between the workspaces, can be found here : Base and Function Workspaces

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by