How do I configure enum in matlab?

6 次查看(过去 30 天)
Jimmy cho
Jimmy cho 2020-12-21
Hi guys,
I would like to ask about how do I define enum in matalb? I know there's enum classes in matalb & object oriented . but what Im asking is something more simple.
As in c/c++ I just was writing the type enum={Long,Short} -an array or list or whatever- and implicitly Long is configured to be equal to 1 (integer number), and short is equal to 2 (integer number).
what Im trying to do in matlab is :
I have function called ReverseBinary and gets one input as parameter called mode , i.e word the format of the function ReverseBinary(Mode) .
the parameter Mode is actually would have just two values Long, Short . and exactly as what I explained above I want to write an enum that Long is configured as 1, Short Configured as 2. So once I define that then I can call the function ReverseBinary(Long) or ReverseBinary(Short) , otherwise the parameters Long and Short aren't defined so I will get compilation error because Long/Short isn't defiend .
note- I call the function ReverseBinary from other funtion.
Any help please how I can do that in Matlab?
thanks alot.

回答(1 个)

Jesús Zambrano
Jesús Zambrano 2020-12-21
Not sure about the exact issue you are having, but please have a look at the way to use Enumerations for, in this case, MATLAB Functino blocks in this link:
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by