How to set Stateflow properties in Stateflow Model Explorer using matlab script?

조회 수: 1 (최근 30일)
Hi all, I know that in Simulink Block Properties / Handles can be called and set using the set_param and get_param commands, respectively. How to do so for Stateflow Model Explorer Properties using matlab script?
>> Example: I have a model called “TestModel.mdl” which contains a Stateflow Chart “MyChart” at a deeper level: ‘TestModel/SubSystem_A/MyChart’. I would like to Add Data in the Model Explorer by means of a command in a m-file, with example properties;
Name: "PresParam_A"
Scope: Parameter
Size: <empty>
Complexity: Off
Type: Double

채택된 답변

Fangjun Jiang
Fangjun Jiang 2018년 6월 22일
편집: Fangjun Jiang 2018년 6월 25일
clear;close all;
sfnew;
rt=sfroot;
ch=rt.find('-isa','Stateflow.Chart');
d1=Stateflow.Data(ch)
then specify the properties of the data
  댓글 수: 3
Shady Nada
Shady Nada 2018년 6월 26일
편집: Shady Nada 2018년 6월 26일
Thanks Fangjun!
It still took a while to figure out how to specify the properties, yet your answer helped me in searching.
For all others who might benefit from this, below the exact solution:
% obtain a handle to the Root object
rt = sfroot;
% Use the handle to the Root object, rt, to find the Model object and assign it a handle as follows
m = rt.find('-isa', 'Simulink.BlockDiagram')
% Access the new Chart object and assign it to the workspace variable as follows
ch = m.find('-isa','Stateflow.Chart');
% Specify Properties
d1 = Stateflow.Data(ch); %add Data
d1.name = 'chm_e_actu_test_state'; %set Name
d1.scope = 'Parameter'; %set Scope
d1.datatype = 'Inherit: Same as Simulink'; %set DataType
% I was not able to speciy 'Complexity' or 'Size'. Be default this is 'Off' and '-1', respectivly.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by