When a user calls reset
on a System object, the internal resetImpl
method is called. In this example,
pCount
is an internal counter property of the Counter
System
object™. When a user calls reset
, pCount
resets to 0.
classdef Counter < matlab.System % Counter System object that increments a counter properties (Access = private) pCount end methods (Access = protected) % Increment the counter and return % its value as an output function c = stepImpl(obj) obj.pCount = obj.pCount + 1; c = obj.pCount; end % Reset the counter to zero. function resetImpl(obj) obj.pCount = 0; end end end
When a user calls release
on a System object, the internal releaseImpl
method is called. This example shows how
to implement the method that releases resources allocated and used by the System
object. These resources include allocated memory and files used for reading or writing.
This method allows you to clear the axes on the Whiteboard figure window while keeping the figure open.
function releaseImpl(obj) cla(Whiteboard.getWhiteboard()); hold on end