You are on page 1of 1

figure, x=[4,3,2,1,2,3,4]; n=0:6;

%% dtft
w=[0:1:500]*pi/500;
X=dtft(x,n,w); magX=abs(X); phaX=angle(X);
subplot(2,1,1); plot(w/pi,magX); grid;
xlabel('frecuency in in pi units'); ylabel('|X|');
title('Magnitude response');
subplot(2,1,2); plot(w/pi,phaX*180/pi); grid;
xlabel('frecuency in in pi units'); ylabel('degreeds');
title('Phase response'); axis([0,1,-180,180]);

figure, x=[4,3,2,1,2,3,4,zeros(1,20)];
N=length(x);
n=0:N-1;
X=dft(x,N);
Omega = 0:pi/100:pi*2;
Xa=dtft(x,n,Omega);
k = 0:N-1;
plot(Omega,abs(Xa),2*k*pi/N,abs(X),'o')
xlabel('\Omega')
ylabel('part a)')

figure, x=[4,3,2,1,2,3,4,zeros(1,20)];
N=length(x);
n=0:N-1;
X=dft(x,N);
Omega = 0:pi/100:pi*2;
Xa=dtft(x,n,Omega);
k = 0:N-1;
plot(Omega,abs(Xa))
xlabel('\Omega')
ylabel('part a)')
hold on

You might also like