Access data type from (.m files) Mathlab functions

조회 수: 5 (최근 30일)
Sinu
Sinu 2025년 2월 19일
답변: Tridib 2025년 2월 24일
I have created .m files with enum values and set a name for this set of enums.
I need to access this enum data type in simulink as well as in state diagrams .
While searching the data type for input port it is not showing this new data type. Is there anyway to access this data type ?

채택된 답변

Tridib
Tridib 2025년 2월 24일
Hello @Sinu,
Here is a sample workflow that I used to utilize custom-defined enumeration classes as data types in Simulink via the “inport” block:
  1. Define the enumeration class in a .m file (In this case, “WeekDays.m”)
classdef WeekDays < Simulink.IntEnumType
enumeration
Day1(0)
Day2(1)
Day3(2)
end
end
2. Using the block parameters dialog box of “inport” block, set Data type of the inport block under the “Signal Attributes” tab to Enum: WeekDays.
3. Use a constant block and set its value to WeekDays.Day2 to have Day2 displayed as the output.
4. The result is displayed using a display block
For more information, you can refer to this documentation:
Hope this helps!

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by