www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/LowpassfilteringawaveformwithtwofrequenciesExample.m

    %% Lowpass filtering a waveform with two frequencies  
% Use an Allpole filter to apply a lowpass filter to a waveform with two
% sinusoidal frequencies.   
%%
% *Note*: This example runs only in R2016b or later. If you are using an 
% earlier release, replace each call to the function with the equivalent 
% |step| syntax. For example, myObject(x) becomes step(myObject,x).

%%  
 t = (0:1000)./8e3;
 xin = sin(2*pi*1e3*t)+sin(2*pi*3e3*t);
 
 hSR = dsp.SignalSource(xin', 4);
 hLog = dsp.SignalSink;
 hallpole = dsp.AllpoleFilter;
 tt = (-25:25)';
 xsinc = 0.4*sinc(0.4*tt);
 asinc = lpc(xsinc,51);
 hallpole.Denominator = asinc;

 h = dsp.SpectrumAnalyzer('SampleRate',8e3,...
    'PlotAsTwoSidedSpectrum',false,...
    'OverlapPercent', 80,'PowerUnits','dBW',...
    'YLimits', [-150 50]);
 
while ~isDone(hSR)
      input = hSR();
      filteredOutput = hallpole(input);
      hLog(filteredOutput);
      h(filteredOutput)
 end

 filteredResult = hLog.Buffer;
 fvtool(hallpole,'Fs',8000)