Access data type from (.m files) Mathlab functions

11 次查看(过去 30 天)
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