%% 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);
 
 src = dsp.SignalSource(xin', 4);
 sink = dsp.SignalSink;
 allpole = dsp.AllpoleFilter;
 tt = (-25:25)';
 xsinc = 0.4*sinc(0.4*tt);
 asinc = lpc(xsinc,51);
 allpole.Denominator = asinc;

 sa = dsp.SpectrumAnalyzer('SampleRate',8e3,...
    'PlotAsTwoSidedSpectrum',false,...
    'OverlapPercent', 80,'PowerUnits','dBW',...
    'YLimits', [-150 50]);
 
while ~isDone(src)
      input = src();
      filteredOutput = allpole(input);
      sink(filteredOutput);
      sa(filteredOutput)
 end

 filteredResult = sink.Buffer;
 fvtool(allpole,'Fs',8000)

%% 
% Copyright 2012 The MathWorks, Inc.