My Math Forum FIR frequency response
 User Name Remember Me? Password

 Applied Math Applied Math Forum

 April 7th, 2014, 09:52 AM #1 Senior Member   Joined: Apr 2014 From: UK Posts: 877 Thanks: 318 FIR frequency response I finally thought it would be a good idea to take a look at FIR filters and have started looking at the math for it. I can generate coefficients for the filter, they match an example I found on the web: FIR Filters by Windowing - The Lab Book Pages My problem is, how do I view the frequency response? None of the math I've tried gives me a graph that looks like the example. I seem to have lost the math I used, it basically ran a bunch of cosines through the tap array, something like freq[m] = sum-of [cos (2 * Pi * h(n) * m)] for n= 0 to 20 repeating for m=0 to 20 Where h(n) is the FIR tap array Any idea what I'm supposed to do?
 April 8th, 2014, 01:55 AM #2 Senior Member   Joined: Apr 2014 From: UK Posts: 877 Thanks: 318 I think I finally have it! given that the example only uses 21 taps, having a frequency plot with only 21 points simply doesn't show enough information, So I multiplied the number of output samples in the frequency by a 'factor'. In case anyone is interested, here's my Excel VBA code to solve it: factor = 10 For j = 0 To (M / 2) * factor Rtot = 0 Itot = 0 For n = 0 To M Am = Worksheets("Sheet1").Cells(n + 1, 1) Re = Am * Cos(2 * Pi * j * n / Taps / factor) Im = -Am * Sin(2 * Pi * j * n / Taps / factor) Rtot = Rtot + Re Itot = Itot + Im Next tot = ((Rtot ^ 2) + (Itot ^ 2)) ^ 0.5 Worksheets("Sheet1").Cells(j + 1, 3) = 20 * Log(tot) Next Taps is 21 and M is Taps-1 (as per the example). the tap values are in "Sheet1" column A, output is "Sheet1" column C
 April 9th, 2014, 12:50 AM #3 Senior Member   Joined: Apr 2014 From: UK Posts: 877 Thanks: 318 Hmmm, although it gives me the right general shape, the amplitudes are off. It looks fine up until the cutoff frequency, it's a little too steep, the first 'hump' is at -50dB instead of about -20dB as per the graph in the example. I believe I've found a small error, in my Cos and Sin maths, Taps should be M, giving: Re = Am * Cos(2 * Pi * j * n / M / factor) Im = Am * Sin(2 * Pi * j * n / M / factor) The amplitude graph (an array of 'tot') looks the same as the example, but my dB graph doesn't [ 20*Log(tot) ] Anyone ideas?
 April 15th, 2014, 06:49 PM #4 Senior Member     Joined: Jul 2012 From: DFW Area Posts: 625 Thanks: 87 Math Focus: Electrical Engineering Applications Hi weirddave, I think that Log() in VBA is the natural log. When I used the natural log instead of the common log in my simulation, the first hump was also around -50 dB. If you divide by Log(10) does it look right? Also, in your equation for the imaginary term, the minus sign disappeared. For the magnitude this does not matter, but it reverses the phase. Thanks from weirddave
 April 16th, 2014, 12:04 AM #5 Senior Member   Joined: Apr 2014 From: UK Posts: 877 Thanks: 318 It does look like the minus sign disappeared, what I didn't mention was that when I changed those equations, I also moved the minus: Itot = Itot - Im Just divided by log(10), brilliant That's done the trick! Woohoo!

 Tags fir, frequency, response

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post Jannamanus Linear Algebra 0 February 19th, 2014 10:39 AM sydfremmer Complex Analysis 11 November 17th, 2012 08:48 PM LeeNoob Economics 0 November 10th, 2011 01:30 PM princessanna57 Economics 1 May 22nd, 2010 09:31 PM MyNameIsVu New Users 7 May 26th, 2009 03:14 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top

Copyright © 2018 My Math Forum. All rights reserved.