www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/FilterASignalUsingBiquadraticFilterExample.m
%% Filter a Signal Using Biquadratic Filter % Use a fourth order, lowpass biquadratic filter object with a normalized % cutoff frequency of 0.4 to filter high frequencies from an input signal. % Display the result as a power spectrum using the Spectrum Analyzer. t = (0:1000)'/8e3; xin = sin(2*pi*0.3e3*t)+sin(2*pi*3e3*t); % Input is 0.3 & % 3kHz sinusoids hFromWS = dsp.SignalSource(xin, 100); hLog = dsp.SignalSink; [z,p,k] = ellip(4,1,60,.4); % Set up the filter [s,g] = zp2sos(z,p,k); hBqF=dsp.BiquadFilter('Structure','Direct form I', ... 'SOSMatrix',s,'ScaleValues',g); h = dsp.SpectrumAnalyzer('SampleRate',8e3,... 'PlotAsTwoSidedSpectrum',false,... 'OverlapPercent', 80,'PowerUnits','dBW',... 'YLimits', [-160 -10]); while ~isDone(hFromWS) input = hFromWS(); filteredOutput = hBqF(input); hLog(filteredOutput); h(filteredOutput) end filteredResult = hLog.Buffer; fvtool(hBqF,'Fs',8000) %% % Design and apply a lowpass biquad filter System object(TM) using the % |design| function. Hd = fdesign.lowpass('Fp,Fst,Ap,Ast',500,550,0.5,60,10000); D = design(Hd,'butter','systemobject',true) fvtool(D);