1
$\begingroup$

I have to design a generic baseband filter. I have a C++ code which gives me filter coefficients based on the input parameters such as no. of taps, no. of bands, band edges, amplitudes and weights(code uses remez exchange algorithm). I import the filter coefficients in MATLAB, do fft and plot the graph of it. I have to shift the graph such that its center is the center of baseband. I know that if I multiply filter coefficients with an exponential function and then do fft the resulting frequency domain output will be shifted in frequency $$x(t) e^{j 2\pi f_0} \implies X(f-f_0)$$. But I dont know how to do it practically. Do I just have to multiply my filter coefficient vector with an exponential like exp^(j*2*pi*f0) and then take fft and plot? I tried doing that but the results of both the graphs are exactly the same.

$\endgroup$
0
$\begingroup$

You are partly right. However It's not the filter coefficinets $a$,$b$, but the filter impulse response $h[n]$ which you have to multiply with the exponential term $e^{j w_0 n}$ to shift its frequency response to a desired center of frequency $w_0$. Note that for FIR filters the coefficients are such that $a=1$ and $b[n]=h[n]$; i.e., the impulse response equals the coefficients $b[k]$, but that's not so with the IIR filters.

Assume that you have an FIR filter with coefficients $a=1$ and $b[k]$ so that its impulse response is: $$h[n] = b[n]$$ And let the frequency response of the filter be $H(e^{j \omega})$, then the frequency response of the new filter $h_+[n] = e^{j w_0 n} h[n]$ will be $$ h_+[n] = e^{j w_0 n} h[n] \implies H_+(e^{j \omega}) = H(e^{j (\omega - \omega_0)}) $$

and similarly the frequency response of the new filter $h_-[n] = e^{-j w_0 n} h[n]$ will be $$ h_-[n] = e^{-j \omega_0 n} h[n] \implies H_-(e^{j \omega}) = H_(e^{j( \omega + \omega_0)}) $$

Note if you want a real impulse response filter, say $h_0[n]$, then you should add those two sub shifted filters: $$ h_0[n] = h_+[n] + h_-[n] \implies H_0(e^{j \omega}) = H_+(e^{j \omega}) + H_-(e^{j \omega}) = H(e^{j (\omega - \omega_0)}) + H(e^{j (\omega + \omega_0)}) $$

You can achieve the same result by the following multiplication then; $$ h_0[n] = 2\cos(\omega_0 n) h[n] \implies H_0(e^{j \omega}) = H(e^{j (\omega - \omega_0)}) + H(e^{j (\omega + \omega_0)}) $$

MATLAB implmenetation would be as follows:

h = fir1(64, 0.1 );     % prototype lowpass filter
L = length(h);

w0 = 0.5*pi;            % bandpass filter new frequency
n = [0:L-1];            % discrete-time index vector 

h0 = 2*cos(w0*n).*h;    % new bandpass filter

% Display prototype lowpass FIR filter
figure,subplot(2,1,1)
stem(n,h);title('Prototype Lowpass filter h[n]');
subplot(2,1,2)
plot(linspace(-1,1,1024), abs(fftshift(fft(h,1024))));
title('DTFT magnitude |H(e^{j \omega})| of lowpass filter h[n]');

% Display new bandpass FIR filter
figure,subplot(2,1,1)
stem(n,h0);title('Prototype Lowpass filter h_0[n]');
subplot(2,1,2)
plot(linspace(-1,1,1024), abs(fftshift(fft(h0,1024))));
title('DTFT magnitude |H_0(e^{j \omega})| of bandpass filter h_0[n]');
$\endgroup$
  • $\begingroup$ Thanks for your explanation. I am working on an FIR filter and so in my case the impulse response would be the same as filter coefficient. Could you tell me if we can achieve same results by multiplying with an exp() function? $\endgroup$ – Preeti Oct 27 '17 at 11:54
  • $\begingroup$ I'm glad this helped. Yes you can achieve the same result by multiplying with complex exponentials $e^{ \pm j \omega_0 n}$ as well.. $\endgroup$ – Fat32 Oct 27 '17 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.