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

No constructor 'Stateflow.State' with matching signature found. Error Matlab

我正在尝试从 sflib (stateflow 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');

它returns我"No constructor 'Stateflow.State' with matching signature found" error. 请问我该如何解决?我不知道这是我在许多 post.

上看到的语法错误还是库错误

add_block return 是添加块的句柄(对于状态图,它实际上是一个子系统。)它不是 return 图表的句柄,这是什么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 API

Access the Model ObjectAccess the Chart Object 部分