%% Filter Responses Using the Prony Method
% Fit a 4th-order IIR model to the impulse response of a lowpass filter. Plot the original and Prony-designed impulse responses.

d = designfilt('lowpassiir','NumeratorOrder',4,'DenominatorOrder',4, ...
    'HalfPowerFrequency',0.2,'DesignMethod','butter');

h = filter(d,[1 zeros(1,31)]);
bord = 4;
aord = 4;
[b,a] = prony(h,bord,aord);

subplot(2,1,1) 
stem(impz(b,a,length(h)))
title 'Impulse Response with Prony Design'

subplot(2,1,2)
stem(h)
title 'Input Impulse Response'

%
% Fit a 10th-order FIR model to the impulse response of a highpass filter. Plot the original and Prony-designed frequency responses. The responses match to high precision.

d = designfilt('highpassfir','FilterOrder',10,'CutoffFrequency',0.8);

h = filter(d,[1 zeros(1,31)]);
bord = 10;
aord = 0;
[b,a] = prony(h,bord,aord);

fvt = fvtool(b,a,d);
legend(fvt,'Prony','Original')

% Copyright 2015 The MathWorks, Inc.