Design a lowpass fourth-order section (FOS) filter using thefdesign
function. 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.
The filter coefficients are scaled using anfdopts.sosscaling
object. The scaling object is defined to have no numerator constraints, and theScaleValueConstraint
is set to'unit'
, specifying the scaling to be unity scaling.
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
.
有限公司nvert the lowpass filter to a bandpass filter using theiirlp2bp
function.
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 = FourthOrderSectionFilter with properties: Numerator: [3x5 double] Denominator: [3x5 double]
Visualize the frequency response of the fourth-order section filter usingfvtool
.
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.
Initialize a spectrum analyzer to visualize the signal spectra.