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

5 Ansichten (letzte 30 Tage)
使用 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 Kommentar
Xiaoning.Wang
Xiaoning.Wang am 4 Jan. 2023
方法一:
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
以编程方式与模型的模型工作区进行交互

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu 编程式模型编辑 finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!