|
|
| enum(names) |
% FILE: enum.m
% PURPOSE: Implement M version of enum
% METHOD: Fill struct with names for 1:n
% USAGE: >> E = enum({'a', 'b', ...});
% >> if E.a == ...
function res = enum(names)
res = struct;
for i =1:numel(names)
res.(names{i}) = uint8(i); % only 255 of them
end
|
|
Contact us at files@mathworks.com