MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

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, Logical)
isComplex = false;
end

methods (Access = protected)
function processInputSpecificationChangeImpl(obj,input1,input2)
if(isreal(input1) && isreal(input2))
obj.isComplex = false;
else
obj.isComplex = true;
end
end
end

Restrict 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.

34 System object Usage and Authoring

Free download pdf