Azzera filtri
Azzera filtri

Facing issue to create enum type

10 visualizzazioni (ultimi 30 giorni)
Sreenivasulu Ozili
Sreenivasulu Ozili il 26 Feb 2013
Commentato: Jordan McBain il 1 Dic 2020
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

Risposte (3)

Nour Salama
Nour Salama il 8 Ott 2020
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 Commento
Jordan McBain
Jordan McBain il 1 Dic 2020
Thank you for providing this answer. It is definitely the solution.

Accedi per commentare.


Abe
Abe il 11 Ago 2014
Did you figure this out?

Zhenwei Sun
Zhenwei Sun il 11 Set 2018
Modificato: Walter Roberson il 11 Set 2018
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.

Categorie

Scopri di più su COM Component Integration in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by