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 Center および File ExchangeSources についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by