I found the answer on MATLAB Answers. Use the following code to set the scope of input number i
to Parameter
:
% Get Stateflow root object
S = sfroot();
% Get block handle
B = S.find('Name','myBlockName','-isa','Stateflow.EMChart');
% Set scope
set(B.Inputs(i), 'Scope', 'Parameter')
Note that you can use B.getChildren()
to access all inputs, outputs and parameters of the block. This is especially useful for parameters, since there is no separate B.Parameters
list (as opposed to B.Inputs
and B.Outputs
).