Access data type from (.m files) Mathlab functions

5 visualizaciones (últimos 30 días)
Sinu
Sinu el 19 de Feb. de 2025
Respondida: Tridib el 24 de Feb. de 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 ?

Respuesta aceptada

Tridib
Tridib el 24 de Feb. de 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!

Más respuestas (0)

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by