Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc; clear all;
- M = 25;
- v = 0:1:M-1;
- rec = zeros(length(M-1));
- tr = zeros(length(M-1));
- ham = zeros(length(M-1));
- han = zeros(length(M-1));
- blk = zeros(length(M-1));
- for n=0:1:M-1
- rec(n+1)=1;
- ham(n+1) = 0.54-(0.46*cos((2*pi*n)/(M-1)));
- han(n+1) = 0.5*(1-cos((2*pi*n)/(M-1)));
- blk(n+1) = 0.42-(0.5*cos((2*pi*n)/(M-1)))+(0.08*cos((4*pi*n)/(M-1)));
- if n<=(M-1)/2
- tr(n+1)=(2*n)/(M-1);
- elseif n>(M-1)/2 && n<=M-1
- tr(n+1)=2-((2*n)/(M-1));
- end
- end
- figure
- title('Time domain response for fixed windows(101915122)');
- subplot(2,3,1)
- plot(v,rec,'b')
- title('rectangular 101915122')
- xlabel('t')
- ylabel('Amplitude')
- subplot(2,3,2)
- plot(v,tr,'m')
- title('triangular')
- xlabel('t')
- ylabel('Amplitude')
- subplot(2,3,3)
- plot(v,ham,'c')
- title('hamming')
- xlabel('t')
- ylabel('Amplitude')
- subplot(2,3,4)
- plot(v,han,'r')
- title('hanning')
- xlabel('t')
- ylabel('Amplitude')
- subplot(2,3,5)
- plot(v,blk,'g')
- title('blackman')
- xlabel('t')
- ylabel('Amplitude')
- xlim([0,M+2]);
- ylim([0,1.1]);
- N=1024
- xaxis= 0:1/N:(N-1)/N
- figure
- title('Frequency domain response for fixed windows(101915122)');
- subplot(2,3,1)
- fftrec= fft(rec,N)
- fyaxis= abs(fftrec/max(fftrec))
- yaxis= 20*log(fyaxis)
- plot(xaxis,fftshift(yaxis),'b')
- title('rectangular 101915122')
- xlabel('freq')
- ylabel('magnitude(db)')
- subplot(2,3,2)
- ffttr= fft(tr,N)
- fyaxis= abs(ffttr/max(ffttr))
- yaxis= 20*log(fyaxis)
- plot(xaxis,fftshift(yaxis),'m')
- title('triangular')
- xlabel('freq')
- ylabel('magnitude(db)')
- subplot(2,3,3)
- fftham= fft(ham,N)
- fyaxis= abs(fftham/max(fftham))
- yaxis= 20*log(fyaxis)
- plot(xaxis,fftshift(yaxis),'c')
- title('hamming')
- xlabel('freq')
- ylabel('magnitude(db)')
- subplot(2,3,4)
- ffthan= fft(han,N)
- fyaxis= abs(ffthan/max(ffthan))
- yaxis= 20*log(fyaxis)
- plot(xaxis,fftshift(yaxis),'r')
- title('hanning')
- xlabel('freq')
- ylabel('magnitude(db)')
- subplot(2,3,5)
- fftblk= fft(blk,N)
- fyaxis= abs(fftblk/max(fftblk))
- yaxis= 20*log(fyaxis)
- plot(xaxis,fftshift(yaxis),'g')
- title('blackman')
- xlabel('freq')
- ylabel('magnitude(db)')
Advertisement
Add Comment
Please, Sign In to add comment