Facing issue to create enum type

Hello,
I am trying to create enum data type. and below is the my smaple code.
classdef OstMode_test < Simulink.IntEnumType
enumeration
Disabled(1)
PredOst(2)
OST(3)
Both(4)
end
methods (Static)
function retVal = getDefaultValue()
retVal = OstMode_test.Both;
end
end
If I run same file on command window I am getting below error.
Error using OstMode_test
Cannot call the constructor of 'OstMode_test' outside of its enumeration block.
Can any body please help me out.
Thanks
Sreenivasulu O

Respuestas (3)

Nour Salama
Nour Salama el 8 de Oct. de 2020

3 votos

You're declaring the enum properly.
The problem is when using it, you should declare the datatype as Enum: OstMode_test and not OstMode_test directly.

1 comentario

Jordan McBain
Jordan McBain el 1 de Dic. de 2020
Thank you for providing this answer. It is definitely the solution.

Iniciar sesión para comentar.

Abe
Abe el 11 de Ag. de 2014

0 votos

Did you figure this out?
Zhenwei Sun
Zhenwei Sun el 11 de Sept. de 2018
Editada: Walter Roberson el 11 de Sept. de 2018

0 votos

in fact what you need do is put the class define file(xxx.m) in in project folder, without run it.
the simulink will automatic match the def.
hope this helps you.

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 26 de Feb. de 2013

Comentada:

el 1 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by