Frequency resolution using Zero Padding | DFT | MATLAB

Codes used in the video:
1)
DFT as sampled version of DTFT:
clc
clear all
close all
n=-20:21;
xn=cos(2*pi*0.2*n);
w=0:0.01:pi;
for i=1:length(w)
    xw(i)=sum(xn.*exp(-1i*w(i)*n));
end
plot(w,abs(xw));
hold on;
N=42;
y=fft(xn,42);
y=y(1:(N/2)+1);
k=0:N/2;
stem(2*pi*k/N,abs(y));

2)
Zero padding concept:
clc
clear all
close all
n=-20:21;
xn=cos(2*pi*0.2*n);
N=512;
y=fft(xn,N);
y=y(1:(N/2)+1);
k=0:N/2;
plot(2*pi*k/N,abs(y));

No comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();