MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

methods (Access = protected)
function flag = isInputComplexityMutableImpl(~,~)
flag = false;
end
function flag = isInputSizeDataTypeImpl(~,~)
flag = false;
end
function flag = isInputSizeMutableImpl(~,~)
flag = false;
end
end


Complete Class Definition File


This CounterSystem object restricts all three aspects of the input specification.


classdef Counter < matlab.System
%Counter Count values above a threshold


properties
Threshold = 1
end


properties (DiscreteState)
Count
end


methods
function obj = Counter(varargin)
setProperties(obj,nargin,varargin{:});
end
end


methods (Access=protected)
function resetImpl(obj)
obj.Count = 0;
end


function y = stepImpl(obj, u1)
if (any(u1 >= obj.Threshold))
obj.Count = obj.Count + 1;
end
y = obj.Count;
end


Handle Input Specification Changes
Free download pdf