Handle Input Specification Changes
This example shows how to control the input specifications for a System object™. You can control what happens when an input specification changes.
You can also restrict whether the input complexity, data type, or size
can change while the object is in use. Whichever aspects you restrict cannot change until
after the user calls release.
React to Input Specification Changes
To modify the System object algorithm or properties when the input changes size, data type, or complexity,
implement the processInputSpecificationChangeImpl method. Specify actions to take when the
input specification changes between calls to the System object.
In this example, processInputSpecificationChangeImpl changes the
isComplex property when either input is
complex.
properties(Access = private)
isComplex (1,1) logical = false;
end
methods (Access = protected)
function processInputSpecificationChangeImpl(obj,input1,input2)
if(isreal(input1) && isreal(input2))
obj.isComplex = false;
else
obj.isComplex = true;
end
end
endRestrict Input Specification Changes
To specify that the input complexity, data type, and size cannot change while the
System object is in use, implement the isInputComplexityMutableImpl, isInputDataTypeMutableImpl, and isInputSizeMutableImpl methods to return false. If you want
to restrict only some aspects of the System object input, you can include only one or two of
these methods.
methods (Access = protected) function flag = isInputComplexityMutableImpl(~,~) flag = false; end function flag = isInputDataTypeMutableImpl(~,~) flag = false; end function flag = isInputSizeMutableImpl(~,~) flag = false; end end
