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

답변 (3개)

Nour Salama
Nour Salama 2020년 10월 8일

3 개 추천

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

Jordan McBain
Jordan McBain 2020년 12월 1일
Thank you for providing this answer. It is definitely the solution.

댓글을 달려면 로그인하십시오.

Abe
Abe 2014년 8월 11일

0 개 추천

Did you figure this out?
Zhenwei Sun
Zhenwei Sun 2018년 9월 11일
편집: Walter Roberson 2018년 9월 11일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2013년 2월 26일

댓글:

2020년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by