Set Model Reference Discrete Sample Time Inheritance
Disallow model reference discrete sample time inheritance for a
System object™. The System object defined in this example has one input, so by default, it allows sample
time inheritance. To override the default and disallow inheritance, the class
definition file for this example includes the
allowModelReferenceDiscreteSampleTimeInheritanceImpl
method,
with its output set to false
.
methods (Access = protected) function flag = ... allowModelReferenceDiscreteSampleTimeInheritanceImpl(obj) flag = false; end end
View the method in the complete class definition file.
classdef MyCounter < matlab.System % MyCounter Count values properties Threshold = 1; end properties (DiscreteState) Count end methods (Static, Access = protected) function header = getHeaderImpl header = matlab.system.display.Header('MyCounter',... 'Title','My Enhanced Counter',... 'Text', 'This counter is an enhanced version.'); end end methods (Access = protected) function flag = ... allowModelReferenceDiscreteSampleTimeInheritanceImpl(obj) flag = false end function setupImpl(obj,u) obj.Count = 0; end function y = stepImpl(obj,u) if (u > obj.Threshold) obj.Count = obj.Count + 1; end y = obj.Count; end function resetImpl(obj) obj.Count = 0; end end end