MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Hide Inactive Properties


To display only active System object properties, use the isInactivePropertyImpl
method. This method specifies whether a property is inactive. An inactive property is a
property that does not affect the System object because of the value of other properties.
When you pass the isInactiveProperty method a property and the method returns
true, then that property is inactive and does not display when the disp function is
called.

Specify Inactive Property


This example uses the isInactiveProperty method to check the value a dependant
property. For this System object, the InitialValue property is not relevant if the
UseRandomInitialValue property is set to true. This isInactiveProperty method
checks for that situation and if UseRandomInitialValue is true, returns true to hide
the inactive InitialValue property.

methods (Access = protected)
function flag = isInactivePropertyImpl(obj,propertyName)
if strcmp(propertyName,'InitialValue')
flag = obj.UseRandomInitialValue;
else
flag = false;
end
end
end

Complete Class Definition File with Inactive Properties
Method

classdef Counter < matlab.System
% Counter Increment a counter

% These properties are nontunable. They cannot be changed
% after the setup method has been called or when the
% object is running.
properties (Nontunable)
% Allow the user to set the initial value
UseRandomInitialValue = true
InitialValue = 0
end

34 System object Usage and Authoring

Free download pdf