clear all
close all
clc

%%%% EN MATLAB TODOS LOS VECTORES EMPIEZAN EN 1
T=15; %%%% longitud total --- en realida es T-2
y(1)=0; %%% seria y[-1]
x(1)=0; %%% seria x[-1]
x(2)=1; %%% seria x[0]
x(3:T)=zeros(1,T-2);
%%%%%%%%%%%%%%%%%%%%%%%%%
b=-0.95;
for n=2:T %%%% n=2 es en realidad n=0;
    y(n)=b*y(n-1)+x(n);
end
plot([0:T-2],y(2:T),'o-')
%hold on
set(gca,'FontSize',20)
xlabel('n')
title(['h[n]=y[n] with b=',num2str(b)])
%axis([0 15 -1 1]) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Omega=-pi:0.01:pi;
Homega=exp(j*Omega)./(exp(j*Omega)-b);
figure
plot(Omega,abs(Homega),'b')
set(gca,'FontSize',20)
xlabel('\Omega')
title(['Module of the Stand. FT, b=',num2str(b)])
axis([-pi pi 0 max(abs(Homega))+0.1]) 


