MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Define Composite System Objects


This example shows how to define System objects that include other System objects.
Define a bandpass filter System object from separate highpass and lowpass filter System
objects.

Store System Objects in Properties

To define a System object from other System objects, store those other objects in your
class definition file as properties. In this example, the highpass and lowpass filters are the
separate System objects defined in their own class-definition files.

properties (Access = private)
% Properties that hold filter System objects
pLowpass
pHighpass
end

Complete Class Definition File of Bandpass Filter Composite System Object

classdef BandpassFIRFilter < matlab.System
% Implements a bandpass filter using a cascade of eighth-order lowpass
% and eighth-order highpass FIR filters.

properties (Access = private)
% Properties that hold filter System objects
pLowpass
pHighpass
end

methods (Access = protected)
function setupImpl(obj)
% Setup composite object from constituent objects
obj.pLowpass = LowpassFIRFilter;
obj.pHighpass = HighpassFIRFilter;
end

function yHigh = stepImpl(obj,u)
yLow = obj.pLowpass(u);
yHigh = obj.pHighpass(yLow);
end

function resetImpl(obj)
reset(obj.pLowpass);

Define Composite System Objects
Free download pdf