I want to encapsulate numbers within a class to hold some meta-information about the number, e.g.
methods obj = myClass(Value,Meta1,Meta2)
myClass.Value = Value;
myClass.Meta1 = Meta1;
myClass.Meta2 = Meta2;
and I would like to be able to operate on this class using functions defined for numbers (reals, complex, integers, etc), which the Value property would contain, e.g.:
>> var = myClass(5.2,'Info1','Info2')
I understand the following mechanism to intercept specific functions:
function out = plus(A,B)
A = A.Value;
B = B.Value;
out = builtin('plus',A,B);
but I wonder if there is a way to intercept all operators so that any time an attempt is made to operate on an object of class 'myClass', it will know to operate only on the Value property of the class? In other words, I don't want to replicate the code above for all functions I would want to be able to use directly on the myClass object, e.g., minus, cos, sign, mldivide.
I also don't want to have to specify the Value property every time, e.g., "cos(var.Value)"