How do I configure enum in matlab?

6 views (last 30 days)
Jimmy cho
Jimmy cho on 21 Dec 2020
Answered: Jesús Zambrano on 21 Dec 2020
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.

Answers (1)

Jesús Zambrano
Jesús Zambrano on 21 Dec 2020
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!

Community Treasure Hunt

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

Start Hunting!