+ Post New Thread
Results 1 to 1 of 1

9th April 2016, 23:34 #1
 Join Date
 Apr 2016
 Posts
 1
 Helped
 0 / 0
 Points
 15
 Level
 1
Plotting frequency response to window sinc funtion in matlab
I am taking DSP and the instructor explains theory but has not shown a single example all semester. One problem on the current homework assignment is to plot the frequency response of a windowed sinc filter using a Blackman window. The sample rate is 10 Khz and cutoff frequency is .195. He has given us M= 800. We are suposed to use the FFT instead of the freqz funtion to plot the normalized response in db from 1500 Hz to 2500 Hz. Here is the code I am trying to use, can anyone see anthing obvious I am missing. I have tried everything I could find so far online to try. The frequency response does look resonable when I use freqz(h).
Code dot  [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
fc = 0.1950; freq = linspace(1500, 2500, 801); s3 = 1; for n = 0: 800; if n == 400 d(s3) = 2*pi*fc; else d(s3) = sin(2.* pi.*fc.*(n 400))./(n400).*(0.42 0.5 .*cos(n.*2.*pi./800)+0.08.*cos(n.*4.*pi/800)); end s3 = s3 +1; end ksum = sum(d); k = 1/ ksum; for n1 = 1: 801 if n1 == 400 h(n1) = 2*pi*fc.*k; else h(n1) = k * sin(2.* pi.*fc.*(n1 400))./(n1400).*(0.42 0.5 .*cos(n1.*2.*pi./800)+0.08.*cos(n1.*4.*pi/800)); end end H = fft(h,1024); for s= 1: 801 ha(s) = (abs(H(s))./H(1)); hdb(s) = 20*log10(ha(s)); ahdb(s) =(abs(hdb(s))); end plot(freq, ahdb), xlabel('Frequency (Hz)'), ylabel('Amplitude(dB)'), title('Frequency Response of Filter'), axis([1500 2500 120 20]);
Last edited by BradtheRad; 9th April 2016 at 23:45. Reason: added code formatted window

Advertisement
+ Post New Thread
Please login