Can not save enumeration created by Stateflow
34 次查看(过去 30 天)
显示 更早的评论
StateFlow can create an enumeration when outputing a monitor port, but can also use a manually created enumeration that match the state names. What I would really like to do is save the StateFlow-created enumeration, and then for future model runs select "Define enumeration type manually". This would a) avoid having to type the enumeration from scratch, and then b) eliminate all the red block highlighting when the model opens (before it builds). Is there a way to do this?
0 个评论
回答(1 个)
Ashok
2024-11-19,3:12
Stateflow does not have a direct feature to output the enumeration definition. here's a workaround that might be useful. In a Stateflow chart where the Enum type 'ModeLogicModeType' is created, the output of the 'Child activity' monitor can be logged using an 'Outport' as shown below.
To gather the enumeration class name, members, and their corresponding numeric values, the following lines of code can be used:
[enumMembers, memberNames] = enumeration(out.yout{1}.Values.Data);
memberValues = double(enumMembers);
enumName = class(out.yout{1}.Values.Data);
This data can then be used to define an enumeration type using the ‘Simulink.defineIntEnumType’ function. More information on this function can be found here:
To list all custom enumerations, present in the current MATLAB session, refer to this MATLAB Answer:
I believe this will assist you!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!