找不到具有匹配签名的构造函数“ Stateflow.State”。错误Matlab

时间:2019-07-05 09:48:59

标签: matlab simulink stateflow

我正在尝试从sflibstateflow library)创建状态块:

chart = add_block('sflib/Chart', 'autoDS/Chart'); %Create Chart Block
state = Stateflow.State(chart); %Create State in Chart Block
state.Name = 'CMD_28V_Avion';
open_system('autoDS');

它返回我"No constructor 'Stateflow.State' with matching signature found" error. 我该如何解决?我不知道这是语法还是库错误,就像我在许多帖子中看到的那样。

1 个答案:

答案 0 :(得分:1)

add_block返回所添加块的句柄(对于状态图来说,它实际上是一个子系统。)它不返回图形中的句柄,Stateflow.State要求将其作为输入。因此是错误。

您需要

add_block('sflib/Chart', 'autoDS/Chart'); %Create Chart Block
rt = sfroot;
m = rt.find('-isa', 'Simulink.BlockDiagram', '-and', 'Name', 'autoDS'); % block diagram
ch = m.find('-isa','Stateflow.Chart', '-and', 'Name', 'Chart'); % chart
st = Stateflow.State(ch); % state
st.Name = 'CMD_28V_Avion';
open_system('autoDS');

请参见Create Charts by Using the Stateflow APIAccess the Model ObjectAccess the Chart Object部分