Access data type from (.m files) Mathlab functions

4 vues (au cours des 30 derniers jours)
Sinu
Sinu le 19 Fév 2025
Réponse apportée : Tridib le 24 Fév 2025
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 ?

Réponse acceptée

Tridib
Tridib le 24 Fév 2025
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!

Plus de réponses (0)

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by