필터 지우기
필터 지우기

What command can I issue to list my custom enumerations which are currently residing in Matlab?

조회 수: 8 (최근 30일)
I have an M-File containing the definitions listed below. I run this M-File so that the enumeration definitions become available to Simulink.
Simulink.defineIntEnumType('engine_state_T', ...
{'ENGINE_IN_STOP','ENGINE_IN_CRANK','ENGINE_IN_STALL', 'ENGINE_IN_RUN', 'ENGINE_IN_AUTOSTOP'}, ...
[0,1,2,3,4])
Simulink.defineIntEnumType('vehicle_state_T', ...
{'VEHICLE_IN_STOP','VEHICLE_IN_CRANK','VEHICLE_IN_STALL'}, ...
[0,1,2])
I want to issue a command from within one of my scripts, much like I do for getting the workspace objects ('who'), so that I can get a list of these enumerations. My script knows nothing about this M-File and simply needs to find the enumeration names that are defined (engine_state_T, vehicle_state_T, etc.)

채택된 답변

goerk
goerk 2015년 10월 20일
A little bit late, but maybe you are still looking for something. I use the following code to get an overview of the defined enumerations.
EnumClassSimulink = meta.class.fromName('Simulink.IntEnumType');
SimulinkClassList = EnumClassSimulink.getAllClasses;
nofClasses = length(SimulinkClassList);
for i=1:nofClasses
if SimulinkClassList{i}.Enumeration
disp(SimulinkClassList{i}.Name)
memberList = SimulinkClassList{i}.EnumerationMemberList;
for j = 1:length(memberList)
disp([ ' ' memberList(j).Name ]);
end
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by