DSPRelated.com
Forums

Amplitude Response ?

Started by Robert A. April 16, 2006
Hi guys,

I'm new to this stuff. I want to calculate the amplitude response so I can 
graph it, I'm using this example:

y(n)=x(n)+x(n-1)

Amplitude Response: G(w)=2.0*cos(Pi*f*T);

According to the tutorial I'm using I think:

f=frequency;
w=2.0*Pi*f;
T=1.0/sample_rate;

...but I'm not really sure because it's all so confusing.

How do I get meaningful values out of that, meaning the gain going from 2.0 
down to 0.0 with frequencies from 0.0 to 22050.0 (half the sample rate) ?

Am I on the right track here ?

Thanks.

PS - I'm doing this all in C(++) so please don't give any MATLAB 
instructions or anything like that.


Robert A. skrev:
> Hi guys, > > I'm new to this stuff. I want to calculate the amplitude response so I can > graph it, I'm using this example: > > y(n)=x(n)+x(n-1) > > Amplitude Response: G(w)=2.0*cos(Pi*f*T); > > According to the tutorial I'm using I think: > > f=frequency; > w=2.0*Pi*f; > T=1.0/sample_rate; > > ...but I'm not really sure because it's all so confusing. > > How do I get meaningful values out of that, meaning the gain going from 2.0 > down to 0.0 with frequencies from 0.0 to 22050.0 (half the sample rate) ? > > Am I on the right track here ?
One reason that might have caused your confusion, is that lots of DSP stuff is explained in "normalized angular frequency", that is, the frequency is expressed as w = 2pi f = [0,...,2*pi] where f = [0,...,1] while the useful stuff relates to "physical frequency" F. Now, the key to unravel this is the sampling frequency (or sampling rate) Fs, Fs = 1/T. Normalizing from physical frequency F to normalized frequency is simple, f = F/Fs = F/(1/T) = FT. Did that help? Rune
Robert A. wrote:

> Hi guys, > > I'm new to this stuff. I want to calculate the amplitude response so I can > graph it, I'm using this example: > > y(n)=x(n)+x(n-1) > > Amplitude Response: G(w)=2.0*cos(Pi*f*T); > > According to the tutorial I'm using I think: > > f=frequency; > w=2.0*Pi*f; > T=1.0/sample_rate; > > ...but I'm not really sure because it's all so confusing. > > How do I get meaningful values out of that, meaning the gain going from 2.0 > down to 0.0 with frequencies from 0.0 to 22050.0 (half the sample rate) ? > > Am I on the right track here ? > > Thanks. > > PS - I'm doing this all in C(++) so please don't give any MATLAB > instructions or anything like that. > >
This is a job for the z transform. Learning the transform itself is a bit of a pain, but once you know it many things come clear. http://www.wescottdesign.com/articles/zTransform/z-transforms.html No Matlab! Robert Lyon's book "Understanding Digital Signal Processing" has a chapter on the z transform, as well as lots of other useful DSP stuff -- here's a link to buy it: http://www.powells.com/partner/30696/biblio/0-13-108989-7. My book, "Applied Control Theory for Embedded Systems" also has a chapter (based on the above article), but mine is really more about feedback control than DSP. Should you be interested anyway, here's a link to buy _it_: http://www.powells.com/partner/30696/biblio/0750678399. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/

"Robert A." wrote:
> > Hi guys, > > I'm new to this stuff. I want to calculate the amplitude response so I can > graph it, I'm using this example: > > y(n)=x(n)+x(n-1) > > Amplitude Response: G(w)=2.0*cos(Pi*f*T); > > According to the tutorial I'm using I think: > > f=frequency; > w=2.0*Pi*f; > T=1.0/sample_rate; >
Yes this looks correct.
> ...but I'm not really sure because it's all so confusing. > > How do I get meaningful values out of that, meaning the gain going from 2.0 > down to 0.0 with frequencies from 0.0 to 22050.0 (half the sample rate) ?
Plugging in 22050 for f and 1/44100 for T you get 0 for the gain at fs/2. Plugging in 0 for f gives you a gain of 2 at DC. Where is the problem? -jim ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
On Sun, 16 Apr 2006 14:05:47 -0700, Tim Wescott <tim@seemywebsite.com>
wrote:

>Robert A. wrote: > >> Hi guys, >> >> I'm new to this stuff. I want to calculate the amplitude response so I can >> graph it, I'm using this example: >> >> y(n)=x(n)+x(n-1) >> >> Amplitude Response: G(w)=2.0*cos(Pi*f*T); >> >> According to the tutorial I'm using I think: >> >> f=frequency; >> w=2.0*Pi*f; >> T=1.0/sample_rate; >> >> ...but I'm not really sure because it's all so confusing. >> >> How do I get meaningful values out of that, meaning the gain going from 2.0 >> down to 0.0 with frequencies from 0.0 to 22050.0 (half the sample rate) ? >> >> Am I on the right track here ? >> >> Thanks. >> >> PS - I'm doing this all in C(++) so please don't give any MATLAB >> instructions or anything like that. >> >> >This is a job for the z transform. Learning the transform itself is a >bit of a pain, but once you know it many things come clear. >
(snipped) Hi Tim, you're not kiddin' that the z-transform makes things clear. If Robert gets serious about learning DSP, he can learn how the z-transform allows him to start with his "y(n)=x(n)+x(n-1)" difference equation and derive the G(w) freq response equation himself. When I was first exposed to the z-transform, I thought that this transform was merely a way for university professors to make our lives miserable. Not so! Knowing how to use the transform as a tool allows us to understand and analyze discrete networks in a very thorough way. Thanks for "preachin' the z-transform gospel" Tim. [-Rick-] Quote of the Day: "Research is what I'm doing when I don't know what I'm doing." -Wernher von Braun
Rick Lyons skrev:

> Quote of the Day: > "Research is what I'm doing when I don't know > what I'm doing." -Wernher von Braun
So... a "researcher" doesn't know what he does? Rune
On Sun, 16 Apr 2006 16:49:17 -0400, "Robert A." <invalid@invalid.org>
wrote:

>Hi guys, > >I'm new to this stuff. I want to calculate the amplitude response so I can >graph it, I'm using this example: > >y(n)=x(n)+x(n-1) > >Amplitude Response: G(w)=2.0*cos(Pi*f*T); > >According to the tutorial I'm using I think: > >f=frequency; >w=2.0*Pi*f; >T=1.0/sample_rate; > >...but I'm not really sure because it's all so confusing. > >How do I get meaningful values out of that, meaning the gain going from 2.0 >down to 0.0 with frequencies from 0.0 to 22050.0 (half the sample rate) ? > >Am I on the right track here ? > >Thanks.
Hi, Here's my two cents: I think you're on the right track. Think, for a moment about your y(n)=x(n)+x(n-1) equation. It says the current output sample is equal to the current input sample plus the previous input sample. OK, now think about a zero-hertz (DC) input such as a long sequence of samples whose values were all seven (7). In this case your output sequence would be a long sequence of samples whose values are all 14. So the system's gain at zero hertz is output/input = 14/7 = 2. Now think about an input sinusoid (with peak value of 7) at the highest frequency that we have in our world of DSP. That frequency is half the sample rate. So an input sequence of +7, -7, +7, -7, etc. would be a discrete sinewave whose freq is half the sample rate. With such an input sequence, what would be the output of your system? That's right, the output would be a sequence of all zeros. So the system's gain at half the sample rate is output/input = 0/7 = 0. Hope that made some sense. Tim Good Luck, [-Rick-]
Rune Allnor wrote:
> Rick Lyons skrev: > > >>Quote of the Day: >> "Research is what I'm doing when I don't know >> what I'm doing." -Wernher von Braun > > > So... a "researcher" doesn't know what he does?
Herr Braun was too stark. Research is what he's doing when he doesn't know what the result will be. " Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins skrev:
> Rune Allnor wrote: > > Rick Lyons skrev: > > > > > >>Quote of the Day: > >> "Research is what I'm doing when I don't know > >> what I'm doing." -Wernher von Braun > > > > > > So... a "researcher" doesn't know what he does? > > Herr Braun was too stark. Research is what he's doing when he doesn't > know what the result will be. "
Wouldn't somebody who knows his trade but is doing new stuff related to his trade be a scientist? What would one call somebody who does stuff that is "trivial" to some profession but new or unknown to himself, and gets paid for it? All right, you have seen enough of my previous rants on the subject, so I'll leave it there. Rune
Tim Wescott wrote:

> Robert A. wrote: > > > Hi guys, > > > > I'm new to this stuff. I want to calculate the amplitude response so I can > > graph it, I'm using this example: > > > > y(n)=x(n)+x(n-1) (1)
...
> This is a job for the z transform. Learning the transform itself is a > bit of a pain, but once you know it many things come clear.
There really is no need to invoke the whole z-transform machinery for such a trivial example. All you need to know is that equation (1) defines an LTI system, which means that a sinusoidal input results in a sinusoidal output with scaled amplitude and shifted phase, ie. L x(n) := x(n) + x(n-1) => L cos(w n) = A(w) cos(w n + phi(w) ), for any 0<= w < pi. Now you can compute A(w) and phi(w) using trigonometric identies: L cos(w n) = cos(w n) + cos(w (n-1)) = cos(w n) + cos(w n) cos(w) + sin(w n) sin(w) = cos(w n) (1+ cos(w) ) + sin(w n) sin(w) = 2 cos(w/2) cos(w n - w/2) Regards, Andor