Facing issue to create enum type
21 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(3 个)
Nour Salama
2020-10-8
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 个评论
Zhenwei Sun
2018-9-11
编辑:Walter Roberson
2018-9-11
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subsystems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!