MATLAB: How to inherite and intialize object values

classinheritanceobject oriented programingoopsubclass

classdef inputDef
properties
nMatch
end
methods
function obj = inputDef(varargin)
p = inputParser;
p.addParameter('nMatch', 1, @isnumeric);
p.parse(varargin{:});
obj.nMatch = p.Results.nMatch; % Position of the sorting parameters
end
end
end
I have a superclass inputDef which has propety nMatch. I create an object and assign a value as below
>>in = inputDef
>>in.nMatch = 2
How do I inherit inputDef in a another class such that I can get
>> out = outDef(in)
>> out.nMatch = 2
classdef outDef < inputDef
properties
...
end
methods
function obj = outDef(obj1)
obj = obj1
end
end
end
Please give some idea. Thanks in advance

Best Answer

What you've shown would work, but you have to actually assign the properties,
function obj = outDef(obj1)
obj.nMatch = obj1.nMatch;
obj.prop1=_____
obj.prop2=_____
etc...
end