How to migrate base workspace data to Model Workspace 如何将base worksapce的数据移植到model workspace中

4 次查看(过去 30 天)
使用 Simulink.ModelWorkspace 对象与模型工作区进行交互。例如,您可以添加和删除变量、设置工作区的数据源以及将更改保存到工作区
Use the Simulink.ModelWorkspace object to interact with the model workspace. For example, you can add and delete variables, set the data source of the workspace, and save changes to the workspace
  1 个评论
Xiaoning.Wang
Xiaoning.Wang 2023-1-4
方法一:
open_system('vdp')
mdlWks = get_param('vdp','ModelWorkspace');
assignin(mdlWks,'myVar',5.12)
方法二:
temp = getVariable(mdlWks,'myVar');
temp = 7.22;
assignin(mdlWks,'myVar',temp)
附加信息:通过查询变量的值来确认新值。
getVariable(mdlWks,'myVar')
ans =
7.2200
大家可以查看help:
Simulink.ModelWorkspace
以编程方式与模型的模型工作区进行交互

请先登录,再进行评论。

采纳的回答

Xiaoning.Wang
Xiaoning.Wang 2023-1-5
Mathework 官方回复:
web(fullfile(docroot, 'simulink/slref/simulink.modelworkspace.html'))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 编程式模型编辑 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!