Main Content

dsp.FourthOrderSectionFilter

Implement cascade of fourth-order section filter

Since R2019a

Description

Thedsp.FourthOrderSectionFilterimplements a cascade of fourth-order section filters.

Creation

Description

fos= dsp.FourthOrderSectionFilter返回一个FourthOrderSectionFilterobject,fos, that implements a cascade of fourth order filter sections.

example

fos= dsp.FourthOrderSectionFilter(num,den)返回一个FourthOrderSectionFilterobject with theNumeratorproperty set tonumand theDenominatorproperty set toden.

example

fos= dsp.FourthOrderSectionFilter(Name,Value)返回一个FourthOrderSectionFilterobject with each specified property name set to the specified value. You can specify additional name-value pair arguments in any order.

Example:fos = dsp.FourthOrderSectionFilter('Numerator',num,'Denominator',den)

Properties

expand all

Numerator coefficients of the filter, specified as anL-by-5 matrix, whereLis the number of filter sections. The size of this property cannot change when the object is locked. However, the values can be modified.

Data Types:single|double
有限公司mplex Number Support:Yes

Denominator coefficients of the filter, specified as anL-by-5 matrix or anL-by-4 matrix, whereLis the number of filter sections. The leading denominator coefficients are assumed to be1always. If the denominator is of sizeL-by-4, one(s) are appended to make the sizeL-by-5. If the denominator is of sizeL-by-5, the first column values are ignored and appended with 1s. The size of this property cannot change when the object is locked. However, the values can be modified.

Data Types:single|double
有限公司mplex Number Support:Yes

Usage

Syntax

Description

y= fos(x)filters the input signal using the specified fourth-order section filter to produce the filtered output,y.

Input Arguments

expand all

Input signal, specified as a vector or a matrix.

The input can be a variable-sized signal, that is, the frame size of each channel (number of rows) can change even after the object is locked. However, the number of channels (number of columns) cannot change.

Data Types:single|double
有限公司mplex Number Support:Yes

Output Arguments

expand all

Filtered output, returned as a vector or a matrix. The output has the same size, data type, and complexity as the input signal.

Data Types:single|double
有限公司mplex Number Support:Yes

Object Functions

expand all

fvtool Visualize frequency response of DSP filters
freqz Frequency response of discrete-time filterSystem object
impz Impulse response of discrete-time filterSystem object
info Information about filterSystem object
coeffs Returns the filterSystem objectcoefficients in a structure
cost Estimate cost of implementing filterSystem object
grpdelay Group delay response of discrete-time filterSystem object
step RunSystem objectalgorithm
释放 Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object
clone Create duplicateSystem object
isLocked Determine ifSystem objectis in use

Examples

collapse all

Filter a noisy sinusoidal signal using thedsp.FourthOrderSectionFilterobject. Visualize the original and filtered signals using a spectrum analyzer.

Input Signal

The input signal is the sum of two sine waves with frequencies 100 Hz and 350 Hz. Add zero-mean white Gaussian noise with a standard deviation of 1e-4 to the sum of sine waves. The sample rate is 1000 Hz.

frameSize = 1024; fs = 1000; Sine1 = dsp.SineWave(5,100,'SamplesPerFrame',1024,'SampleRate',fs); Sine2 = dsp.SineWave(2,350,pi/2,'SamplesPerFrame',1024,...'SampleRate',fs); x = Sine1()+Sine2()+1e-4.*randn(Sine1.SamplesPerFrame,1);

Fourth-Order Section (FOS) Filter Coefficients

The numerator and denominator coefficients for the FOS filter are obtained usingdesignParamEqwhich is part of Audio Toolbox:

%N = [2,4];%gain = [5,10];%centerFreq = [0.025,0.75];%bandwidth = [0.025,0.35];%mode = 'fos';%[num,den] = designParamEQ(N,gain,centerFreq,bandwidth,mode,'Orientation','row');num = [1.0223 -1.9368 0.9205 0 0 1.5171 2.3980 1.4317 0.6416 0.2752]; den = [-1.9368 0.9428 0 0 2.0136 1.9224 1.0260 0.3016];

Initialize Filter and Spectrum Analyzer

有限公司nstruct the FOS IIR filter using thenumanddencoefficients. Construct a spectrum analyzer to visualize the original sinusoidal signal and the filtered signal.

fos = dsp.FourthOrderSectionFilter('Numerator',num,...'Denominator',den); scope = spectrumAnalyzer(...'SampleRate',fs,...'PlotAsTwoSidedSpectrum',false,...'FrequencyScale','linear',...'Method','welch',...'Title','Original and Filtered Signals',...'ShowLegend',true,...'ChannelNames',{'Original Signal','Filtered Signal'});

Filter the input signal, and visualize the original and filtered spectrums.

fori = 1:10000 y = fos(x); scope([x,y]);end释放(scope);

Design a lowpass fourth-order section (FOS) filter using thefdesignfunction. Using this filter, filter a noisy sinusoidal signal with two tones, one at 3 kHz, and the other at 12 kHz.

Design a fifth-order filter using the elliptic method in the'df2tsos'structure. Use L-infinity norm scaling in the frequency domain. Specify the passband frequency to be 0.15 π rad/sample and the stopband frequency to be 0.25 π rad /样品。指定1 dBllowable passband ripple and a stopband attenuation of 60 dB.

Fp = 0.15; Fst = 0.25; Ap = 1; Ast = 60;

The filter coefficients are scaled using anfdopts.sosscalingobject. The scaling object is defined to have no numerator constraints, and theScaleValueConstraintis set to'unit', specifying the scaling to be unity scaling.

fdo = fdopts.sosscaling; fdo.NumeratorConstraint='none'; fdo.ScaleValueConstraint='unit'; f = fdesign.lowpass('Fp,Fst,Ap,Ast',Fp,Fst,Ap,Ast); hFilter = design(f,'ellip','SystemObject',true,...'FilterStructure','df2tsos','SOSScaleNorm','Linf',...'SOSScaleOpts',fdo)
hFilter = dsp.SOSFilter with properties: Structure: 'Direct form II transposed' CoefficientSource: 'Property' Numerator: [3x3 double] Denominator: [3x3 double] HasScaleValues: true ScaleValues: [1 1 1 1.0000] Show all properties

Visualize the lowpass frequency response of the designed filter usingfvtool.

fvtool(hFilter)

Figure Figure 1: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank r a d / s a m p l e ), ylabel Magnitude (dB) contains 2 objects of type line.

有限公司nvert the lowpass filter to a bandpass filter using theiirlp2bpfunction.

[num,den] = iirlp2bp(hFilter.Numerator,hFilter.Denominator,Fp,[0.25,0.75])
num =3×50.2456 0 -0.2456 0 0 0.4175 -0.0000 -0.4206 -0.0000 0.4175 0.4281 -0.0000 -0.6433 -0.0000 0.4281
den =3×51.0000 -0.0000 0.5088 0 0 1.0000 -0.0000 0.0060 -0.0000 0.8657 1.0000 -0.0000 0.5160 -0.0000 0.5283

Create a fourth-order section filter using these numerator and denominator coefficients.

fos = dsp.FourthOrderSectionFilter(num,den)
fos = FourthOrderSectionFilter with properties: Numerator: [3x5 double] Denominator: [3x5 double]

Visualize the frequency response of the fourth-order section filter usingfvtool.

fvtool(fos);

Figure Figure 2: Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB), xlabel Normalized Frequency ( times pi blank r a d / s a m p l e ), ylabel Magnitude (dB) contains an object of type line.

Filter a noisy input signal with the fourth-order section filter. Visualize the spectra of the original signal and the filtered signal using the spectrum analyzer.

The input is a sum of two sine waves with frequencies 3 kHz and 12 kHz, respectively. The input sample rate is 44.1 kHz, and the frame size is set to 1024 samples.

fs = 44100; FrameLength = 1024; SINE1 = dsp.SineWave('SamplesPerFrame',FrameLength,'SampleRate',fs,'Frequency',3000); SINE2 = dsp.SineWave('SamplesPerFrame',FrameLength,'SampleRate',fs,'Frequency',12000);

Initialize a spectrum analyzer to visualize the signal spectra.

scope = spectrumAnalyzer(...'SampleRate',fs,...'PlotAsTwoSidedSpectrum',false,...'Title','Original and Filtered Signals',...'ShowLegend',true,...'YLimits',[-180 50],...'ChannelNames',{'Original Signal','Filtered Signal'});for指数= 1:1000 x = SINE1 SINE2 () + () + 0.001 * randn (FrameLength,1); y = fos(x); scope([x,y]);end

Version History

Introduced in R2019a

See Also

Objects

Blocks