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

5 visualizzazioni (ultimi 30 giorni)
使用 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 Commento
Xiaoning.Wang
Xiaoning.Wang il 4 Gen 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
以编程方式与模型的模型工作区进行交互

Accedi per commentare.

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su 编程式模型编辑 in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!