There's a few problems with attempting to do this in MATLAB. First, though you can make an enumeration a subclass of a built-in type - you can't do it unless your enumerations are each a specific scalar value of the superclass type. Instead, you should make it not a subclass of a built in type and instead make properties of that type, as follows:
classdef Quaternion
enumeration
U( [ 1, 0; 0, 1] )
I( [ 1i, 0; 0, -1i] )
J( [ 0, -1; 1, 0] )
K( [ 0, 1i; 1i, 0] )
end
properties
q double;
end
methods
function obj = Quaternion(q)
arguments
q (2, 2) double;
end
obj.q = q;
end
end
end
You could also make the constructor have 2 or 4 inputs, each representing either a row or individual element of your matrix, if you wanted - and could map that to a single or multiple properties as well. For example, the constructor could be obj = Quaternion(a,b,c,d) and then set obj.q = [ a, b; c, d] and validate that each input is a 1x1 scalar if you want to do validation.