주요 콘텐츠

cascade

Cascade of filter system objects

Description

FC = cascade(obj1,obj2,...objn) returns an object, FC, of type dsp.FilterCascade. FC is a cascaded version of the input System objects obj1, obj2,....objn. You can input multiple System objects to the function. The input System objects must be supported by the cascade method. For the list of supported System objects, see Input Arguments.

example

FC = cascade(___,InputSampleRate=Value) specifies the input sample rate of the filter cascade as one of these options:

  • Positive real scalar — The input sample rate of the filter cascade is a positive real scalar.

  • "normalized" — The input sample rate of the filter cascade is in normalized frequency units regardless of the input sample rate of the individual filter stages.

  • "auto" — The input sample rate of the filter cascade is determined from the input sample rate of the individual filter stages as per these conditions:

    • If all the filter stages have a normalized frequency, then the filter cascade has a normalized frequency.

    • If at least one filter stage has an absolute sample rate, then the filter cascade uses an absolute sample rate. The object determines this rate based on the rate conversion ratio of the stages within. For an example, see Specify Input Sample Rate in dsp.FilterCascade Object.

(since R2026a)

Examples

collapse all

Design a two-stage decimator by cascading dsp.CICDecimator and dsp.CICCompensationDecimator System objects.

Construct the objects

CICDecim = dsp.CICDecimator(DecimationFactor=6, ...
                            NumSections=6);
fs = 16e3;     % Sampling frequency of input of compensation decimator
fPass = 4e3;   % Passband frequency
fStop = 4.5e3; % Stopband frequency
CICCompDecim = dsp.CICCompensationDecimator(CICDecim, ...
                              DecimationFactor=2, ...
                              PassbandFrequency=fPass, ...
                              StopbandFrequency=fStop, ...
                              SampleRate=fs);

Create a cascade of the two objects using the cascade method

 FC = cascade(CICDecim, CICCompDecim);

Visualize the frequency response of the cascade

 f = filterAnalyzer(CICDecim,CICCompDecim,FC,SampleRates=[fs*6,fs,fs*6],...
        Arithmetic="fixed",NormalizeMagnitude=true);
setLegendStrings(f,["CIC Decimator","CIC Compensation Decimator","Overall Response"]);

Since R2026a

Specify the input sample rate explicitly while constructing the dsp.FilterCascade object using the InputSampleRate argument.

Cascade with Absolute Sample Rate

Create a dsp.FilterCascade object with three stages. Each stage is a dsp.FIRFilter object operating in normalized frequency units. Specify the sample rate of the cascade as 22050 Hz using the InputSampleRate argument.

filtNorm1 = dsp.FIRFilter;
firtNorm2 = dsp.FIRFilter(designLowpassFIR(FilterOrder=30,CutoffFrequency=0.5,Window="hann"));
filtNorm3 = designLowpassFIR(FilterOrder=10,CutoffFrequency=0.5,SystemObject=true);
cascadeSpecifySampleRate = cascade(filtNorm1,firtNorm2,filtNorm3,InputSampleRate=22050)
cascadeSpecifySampleRate = 
  dsp.FilterCascade with properties:

         Stage1: [1×1 dsp.FIRFilter]
         Stage2: [1×1 dsp.FIRFilter]
         Stage3: [1×1 dsp.FIRFilter]
    CloneStages: true

The cascade operates at the absolute frequency that you specify regardless of the sample rate of the filter stages.

info(cascadeSpecifySampleRate)
ans = 
    'Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 3
     Stage cloning: enabled
     Input sample rate: 22050
     ----------------------------
     
     Stage1: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 2              
     Stable            : Yes            
     Linear Phase      : Yes (Type 2)   
     Input sample rate : Normalized     
     
     
     Stage2: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 31             
     Stable            : Yes            
     Linear Phase      : Yes (Type 1)   
     Input sample rate : Normalized     
     
     
     Stage3: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 11             
     Stable            : Yes            
     Linear Phase      : Yes (Type 1)   
     Input sample rate : Normalized     
     
     '

Cascade with Normalized Sample Rate

Specify normalized sample rate on the cascade. The first stage of the filter cascade has a sample rate of 17 Hz. The remaining filter stages operate in normalized frequency units.

filtAbs1 = dsp.FIRFilter(SampleRate=17);
firtNorm2 = dsp.FIRFilter(designLowpassFIR(FilterOrder=30,CutoffFrequency=0.5,Window="hann"));
filtNorm3 = designLowpassFIR(FilterOrder=10,CutoffFrequency=0.5,SystemObject=true);
cascadeNormSampleRate = cascade(filtAbs1,firtNorm2,filtNorm3,InputSampleRate="normalized")
cascadeNormSampleRate = 
  dsp.FilterCascade with properties:

         Stage1: [1×1 dsp.FIRFilter]
         Stage2: [1×1 dsp.FIRFilter]
         Stage3: [1×1 dsp.FIRFilter]
    CloneStages: true

The cascade operates in normalized frequency units regardless of the sample rate of the individual filter stages.

info(cascadeNormSampleRate)
ans = 
    'Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 3
     Stage cloning: enabled
     Input sample rate: Normalized
     ----------------------------
     
     Stage1: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 2              
     Stable            : Yes            
     Linear Phase      : Yes (Type 2)   
     Input sample rate : 17             
     
     
     Stage2: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 31             
     Stable            : Yes            
     Linear Phase      : Yes (Type 1)   
     Input sample rate : Normalized     
     
     
     Stage3: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 11             
     Stable            : Yes            
     Linear Phase      : Yes (Type 1)   
     Input sample rate : Normalized     
     
     '

Cascade with Auto Sample Rate

Set the input sample rate of the cascade to "auto". The individual filter stages have a combination of normalized and absolute sample rates. The cascade uses the absolute sample rate.

filtAbs1 = dsp.FIRFilter(SampleRate=17);
firtNorm2 = dsp.FIRFilter(designLowpassFIR(FilterOrder=30,CutoffFrequency=0.5,Window="hann"));
filtAbs2 = dsp.FIRFilter(designLowpassFIR(FilterOrder=10,CutoffFrequency=0.5),SampleRate=17);
cascadeAutoSampleRate = cascade(filtAbs1,firtNorm2,filtAbs2,InputSampleRate="auto");
info(cascadeAutoSampleRate)
ans = 
    'Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 3
     Stage cloning: enabled
     Input sample rate: 17
     ----------------------------
     
     Stage1: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 2              
     Stable            : Yes            
     Linear Phase      : Yes (Type 2)   
     Input sample rate : 17             
     
     
     Stage2: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 31             
     Stable            : Yes            
     Linear Phase      : Yes (Type 1)   
     Input sample rate : Normalized     
     
     
     Stage3: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 11             
     Stable            : Yes            
     Linear Phase      : Yes (Type 1)   
     Input sample rate : 17             
     
     '

The input sample rate of the cascade is set to "auto". If there is a conversion ratio in the individual filter stages, the input sample rate of the cascade takes the conversion ratio into account. The second stage drops the sample rate by 3 and the third stage paces the cascade at 17 Hz. Therefore, the input sample rate of the cascade is 3×17 = 51 Hz.

filtNorm1 = dsp.FIRFilter; % Normalized frequency
filtNorm4 = dsp.FIRDecimator(3);  % Normalized frequency
filtAbs3 = dsp.SOSFilter(SampleRate=17); % Absolute frequency
cascadeAutoSampleRate2 = cascade(filtNorm1,filtNorm4,filtAbs3,InputSampleRate="auto");
info(cascadeAutoSampleRate2)
ans = 
    'Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 3
     Stage cloning: enabled
     Input sample rate: 51
     ----------------------------
     
     Stage1: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 2              
     Stable            : Yes            
     Linear Phase      : Yes (Type 2)   
     Input sample rate : Normalized     
     
     
     Stage2: dsp.FIRDecimator
     -------
     Discrete-Time FIR Multirate Filter (real)               
     -----------------------------------------               
     Filter Structure   : Direct-Form FIR Polyphase Decimator
     Decimation Factor  : 3                                  
     Polyphase Length   : 24                                 
     Filter Length      : 72                                 
     Stable             : Yes                                
     Linear Phase       : Yes (Type 1)                       
                                                             
     Arithmetic         : double                             
     Input sample rate : Normalized                          
     
     
     Stage3: dsp.SOSFilter
     -------
     Discrete-Time IIR Filter (real)                                       
     -------------------------------                                       
     Filter Structure    : Direct-Form II Transposed, Second-Order Sections
     Number of Sections  : 1                                               
     Stable              : Yes                                             
     Linear Phase        : No                                              
     Input sample rate : 17                                                
     
     '

Consider a cascade with nested cascades. The input sample rate of the first cascade is 22050 Hz. The input sample rate of the second cascade is "normalized". Cascade these two filter structures and set the input sample rate of the overall filter cascade to "auto".

filtCascadeSpecifySampleRate = dsp.FilterCascade(InputSampleRate=22050)
filtCascadeSpecifySampleRate = 
  dsp.FilterCascade with properties:

         Stage1: [1×1 dsp.FIRFilter]
    CloneStages: true

filtCascadeNormSampleRate = dsp.FilterCascade(InputSampleRate="normalized")
filtCascadeNormSampleRate = 
  dsp.FilterCascade with properties:

         Stage1: [1×1 dsp.FIRFilter]
    CloneStages: true

filtNestedCasacade = cascade(filtCascadeSpecifySampleRate,filtCascadeNormSampleRate,InputSampleRate="auto")
filtNestedCasacade = 
  dsp.FilterCascade with properties:

         Stage1: [1×1 dsp.FilterCascade]
         Stage2: [1×1 dsp.FilterCascade]
    CloneStages: true

The first filter cascade has an absolute sample rate and the second filter cascade operates in normalized frequency units. The nested filter cascade in the "auto" configuration uses the absolute sample rate.

info(filtNestedCasacade)
ans = 
    'Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 2
     Stage cloning: enabled
     Input sample rate: Normalized
     ----------------------------
     
     Stage1: dsp.FilterCascade
     -------
     Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 1
     Stage cloning: enabled
     Input sample rate: 22050
     ----------------------------
     
     Stage1: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 2              
     Stable            : Yes            
     Linear Phase      : Yes (Type 2)   
     Input sample rate : Normalized     
     
     
     
     
     Stage2: dsp.FilterCascade
     -------
     Discrete-Time Filter Cascade
     ----------------------------
     Number of stages: 1
     Stage cloning: enabled
     Input sample rate: Normalized
     ----------------------------
     
     Stage1: dsp.FIRFilter
     -------
     Discrete-Time FIR Filter (real)    
     -------------------------------    
     Filter Structure  : Direct-Form FIR
     Filter Length     : 2              
     Stable            : Yes            
     Linear Phase      : Yes (Type 2)   
     Input sample rate : Normalized     
     
     
     
     '

Input Arguments

collapse all

obj1, obj2,....objn are filters to be cascaded. To see the list of System objects you can pass to the cascade method, type

dsp.FilterCascade.helpSupportedSystemObjects
in the MATLAB® command prompt.

Input sample rate of the filter cascade, specified as one of these:

  • Positive real scalar — The input sample rate of the filter cascade is a positive real scalar.

  • "normalized" — The input sample rate of the filter cascade is in normalized frequency units regardless of the input sample rate of the individual filter stages.

  • "auto" — The input sample rate of the filter cascade is determined from the input sample rate of the individual filter stages as per these conditions:

    • If all the filter stages have a normalized frequency, then the filter cascade has a normalized frequency.

    • If at least one filter stage has an absolute sample rate, then the filter cascade uses an absolute sample rate. The object determines this rate based on the rate conversion ratio of the stages within.

Data Types: single | double | char | string

Output Arguments

collapse all

Cascaded filter, returned as a System object of type dsp.FilterCascade. For information on the properties of the filter in each stage, type info(FC) in the MATLAB command prompt.

Version History

Introduced in R2016a

expand all