Search code examples
matlaboctaveenumeration

Does Octave support enumeration like Matlab?


Does Octave support enumeration like Matlab?
I haven't found any info about it.

We can create an enumeration class by adding an enumeration block to a class definition. For example, the WeekDays class enumerates a set of days of the week (from Matlab doc).

%file WeekDays.m
classdef WeekDays
   enumeration
      Monday, Tuesday, Wednesday, Thursday, Friday
   end
end

And it work well in Matlab and I access enum values as

x = WeekDays.Tuesday;

but Octave doesn't compile this line, despite file WeekDays.m is compiled by Octave without errors.


Solution

  • I believe that in Octave version 4.0 there is experimental support for classdef-based object-oriented code, including enumeration blocks.

    Edit: looks like I was wrong, and enumerations are not yet supported, as indicated in the comment below from @carandraug (who I believe is an Octave developer, so probably knows better then me).