# Filter graphing help

#### MYMLA

1. Homework Statement
Calculate and graph the response of the filter:

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

at the frequencies: i) 0 Hz, ii) sr/4, iii) sr/2 (Nyquist frequency).

2. Homework Equations

3. The Attempt at a Solution
If I put each of those into the formula as n? But how do i know what sample rate/4 is? I'm guessing that it's a low pass.

Related Introductory Physics Homework Help News on Phys.org

#### berkeman

Mentor
1. Homework Statement
Calculate and graph the response of the filter:

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

at the frequencies: i) 0 Hz, ii) sr/4, iii) sr/2 (Nyquist frequency).

2. Homework Equations

3. The Attempt at a Solution
If I put each of those into the formula as n? But how do i know what sample rate/4 is? I'm guessing that it's a low pass.
Yes, it does look like a lowpass filter. Your sample rate is just integers -- 1, 2, 3, 4, etc. The SR/2 is just every other sample, the SR/4 is just every 4th sample, etc.

So can you show us what you get for the frequencies above? Just input 1's and 0's as indicated.

#### MYMLA

Yes, it does look like a lowpass filter. Your sample rate is just integers -- 1, 2, 3, 4, etc. The SR/2 is just every other sample, the SR/4 is just every 4th sample, etc.

So can you show us what you get for the frequencies above? Just input 1's and 0's as indicated.

I'm confused. so I just plug in 1's and 0's into the formula?

#### berkeman

Mentor
I'm confused. so I just plug in 1's and 0's into the formula?
I'm assuming the x() are the inputs and y() is the output, right? So for the first DC case, input all 1's and see what you get for the y(n) outputs. Then for an input frequency of SR/2, you would have alternating 1's and 0's. For SR/4, you would have two 1's in a row followed by two 0's in a row, and so on. You should then be able to keep lowering the frequency of the input variations to see what kind of a frequency response you get.

#### MYMLA

I'm assuming the x() are the inputs and y() is the output, right? So for the first DC case, input all 1's and see what you get for the y(n) outputs. Then for an input frequency of SR/2, you would have alternating 1's and 0's. For SR/4, you would have two 1's in a row followed by two 0's in a row, and so on. You should then be able to keep lowering the frequency of the input variations to see what kind of a frequency response you get.
That makes more sense but how do I get the all ones, one zero one zero and two ones two zeros part? is that always the same?. Thankyou for the help.

#### berkeman

Mentor
That makes more sense but how do I get the all ones, one zero one zero and two ones two zeros part? is that always the same?. Thankyou for the help.
You just work it out by hand, I guess. Alternately you can do this in Excel -- I do a lot of my basic digital filter checks in Excel. You just make a column for n that counts 1, 2, 3, 4, ... And then the next column is x(n), and the next column is y(n). You put a formula into the 2nd cell down for y(n) so you can add the x(n) and x(n-1) terms using the formula you were given. Then just click that y(2) cell and drag it down a ways, and do a Fill-Down. That pastes the formula into all the cells in that column.

You would make Excel sheets for each of the input sequences. One for the DC case where x(n)=1 for all n, one for the SR/2 case where you alternate 1/0 in each row, etc.

#### MYMLA

You just work it out by hand, I guess. Alternately you can do this in Excel -- I do a lot of my basic digital filter checks in Excel. You just make a column for n that counts 1, 2, 3, 4, ... And then the next column is x(n), and the next column is y(n). You put a formula into the 2nd cell down for y(n) so you can add the x(n) and x(n-1) terms using the formula you were given. Then just click that y(2) cell and drag it down a ways, and do a Fill-Down. That pastes the formula into all the cells in that column.

You would make Excel sheets for each of the input sequences. One for the DC case where x(n)=1 for all n, one for the SR/2 case where you alternate 1/0 in each row, etc.
Sorry i'm just getting more confused. Where did you get the 1 for all n from and the alternate one. How do you know its 1 for all n and alternating?

#### berkeman

Mentor
Sorry i'm just getting more confused. Where did you get the 1 for all n from and the alternate one. How do you know its 1 for all n and alternating?
This is for a digital filter, right? So the input to the digital filter is a single bit that can take values of 0 or 1, and can change for each n. You can have an input bitstream that is 100 bits long, numbered n=1, n=2, n=3, etc.

The problem asks you what the output of your filter equation is for frequency = 0Hz. That means that the input value is holding steady at either a 0 or a 1 always for the whole bitstream. Having x(n) = 0 for the whole bitstream is pretty uninteresting, so instead set them all to 1. The output of your digital filter equation for each value of n will be the response of the filter to a DC input signal of x(n) = 1.

Then to find out what the response of the filter is to the highest frequency input that you can have, you want to make the x(n) alternate between 0 and 1 each time. That looks to be what they are calling the SR/2 case. Then you can do lower frequencies like SR/4 by changing the x(n) in each row of your spreadsheet more slowly.

#### collinsmark

Homework Helper
Gold Member
1. Homework Statement
Calculate and graph the response of the filter:

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

at the frequencies: i) 0 Hz, ii) sr/4, iii) sr/2 (Nyquist frequency).

2. Homework Equations

3. The Attempt at a Solution
If I put each of those into the formula as n? But how do i know what sample rate/4 is? I'm guessing that it's a low pass.
Yes, it does look like a lowpass filter. Your sample rate is just integers -- 1, 2, 3, 4, etc. The SR/2 is just every other sample, the SR/4 is just every 4th sample, etc.

So can you show us what you get for the frequencies above? Just input 1's and 0's as indicated.
This is for a digital filter, right? So the input to the digital filter is a single bit that can take values of 0 or 1, and can change for each n. You can have an input bitstream that is 100 bits long, numbered n=1, n=2, n=3, etc.
@berkeman, I'm not sure if that's that's quite right. I don't see any indication in the problem statement that the filter is quantized in amplitude. It is obviously a discrete-time filter, in that it is quantized in the time domain, but as far as I can tell the amplitudes can take on any value.

To me it appears that the problem statement is asking for the frequency response, where the input function is assumed to be sinusoidal such as
$$x[n] = A e^{j \frac{\omega}{\omega_s} n}$$
where
$$e^{j \theta} = \cos \theta + j \sin \theta,$$
$$\omega = 2 \pi f,$$
$$\omega_s = 2 \pi f_s,$$
and for this particular problem,
$$f = 0 \ \mathrm{Hz}, \ \frac{f_s}{4}, \ \frac{f_s}{2}.$$

@MYMLA should be able to confirm that. MYMLA, is there there a specific input waveform, $x[n]$, that you are expected to use or is the input assumed to be sinusoidal?

What's not clear in the problem statement though if it is asking to calculate and graph the frequency response or the transient response.

If you are being asked to calculate the frequency response, $H(e^{j \frac{\omega}{\omega_s}}) = \frac{Y(e^{j \frac{\omega}{\omega_s}})}{X(e^j {\frac{\omega}{\omega_s}})}$, there is more than one way to approach the problem. You could take the discrete-time Fourier transform of the impulse response, $h[n]$, or you could calculate the steady-state ratio of $\frac{y[n]}{x[n]}$ (the "steady state" ratio assumes that $n$ approaches infinity, but that's easy here since the filter has a finite impulse response. This latter method also assumes that $x[n]$ is sinusoidal as expressed above [i.e., $x[n] = A e^{j \frac{\omega}{\omega_s} n}$ ]). Note that the frequency response is complex, and has a varying magnitude and phase as function of the input frequency.

If you are being asked to calculate the transient response (instead of the frequency response), then you need a specific input signal. I sort of doubt this is what is being asked of you unless the problem gives you more information than was given here.

[Edit: The "impulse response" of which I spoke earlier, is special case of the transient response where the input signal is $x[n] = \delta[n]$. This is an easy to calculate waveform for a FIR filter. The discrete-time Fourier transform of the impulse response is the filter's "frequency response," as expressed as a function of frequency.]

Last edited:

#### berkeman

Mentor
I'm not sure if that's that's quite right. I don't see any indication in the problem statement that the filter is quantized in amplitude. It is obviously a discrete-time filter, in that it is quantized in the time domain, but as far as I can tell the amplitudes can take on any value.
You may be right. At the very least the values x(n) could be multi-bit values, rather than the single-bit example I was thinking of. And the filter response would be a lot clearer if the values could be multi-bit. Thanks for seeing that.

#### MYMLA

I'm still confused by this :/

#### Attachments

• 40.4 KB Views: 199
• 40.4 KB Views: 222

Homework Helper
Gold Member