%% recursion.m computes the response of a difference system recursively 
% time vector
n=0:1:15;
% define the input signal
x=[1 zeros(1,length(n)-1)];
y=zeros(1,length(n));
% initial conditions
yn_1=0;
yn_2=0;
xn_1=0;
xn=0;
% recursion
for k=1:length(n)
   xn=x(k);
   yn=(5/6)*yn_1-(1/6)*yn_2+3*xn-2*xn_1;
   y(k)=yn;
   yn_2=yn_1;
   yn_1=yn;
   xn_1=xn;
end
% plot output
stem(n,y)

