Clear Filters
Clear Filters

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

4 views (last 30 days)
使用 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 Comment
Xiaoning.Wang
Xiaoning.Wang on 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
以编程方式与模型的模型工作区进行交互

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on 编程式模型编辑 in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!