I have a counter:
classdef Commands
properties
commandString;
readonly;
end
methods
function obj = Commands(commandString, readonly)
obj.commandString = commandString;
obj.readonly= readonly;
end
end
enumeration
PositionMode('p', false)
TravelDistance('s', false)
end
end
and I have a line:
currentCommand = 'PositionMode';
I want to be able to return:
Commands.PositionMode
Is there a better solution than
methods(Static)
function obj = str2Command(string)
obj = eval(['Commands.' string]);
end
end
source
share