It might be interesting to interpret the output of the fft() function in Matlab. Consider the following simple examples.
fsMHz = 20; % sampling frequency
fcMHz = 1.5625; % signal frequency
N = 128; % fft size
% generating the time domain signal
x1T = exp(j*2*pi*fcMHz*[0:N-1]/fsMHz);
x1F = fft(x1T,N); % 128 pt FFT
figure;
plot([-N/2:N/2-1]*fsMHz/N,fftshift(abs(x1F))) ; % sub-carriers from [-128:127]
xlabel('frequency, MHz')
ylabel('amplitude')
title('frequency response of complex sinusoidal signal');
With anpoint fft() and sampling frequency of
, the observable spectrum from
is split to
sub-carriers.
Additionally, the signal at the output of fft() is from . As the frequencies from
get aliased to
, the operator fftshift() is used when plotting the spectrum.
In the example above, with a sampling frequency of 20MHz, the spectrum from [-10MHz, +10MHz) is divided into 128 sub-carriers with spaced apart by 20MHz/128 = 156.25kHz. The generated signal x1T of frequency 1.5625MHz corresponds to the information on the 10th sub-carrier, which can also be generated in the frequency domain.
% generating the frequency domain signal with subcarrier indices [-N/2:-1 dc 1:N/2-1] x2F = [zeros(1,N/2) 0 zeros(1,9) 1 zeros(1,N/2-10-1)]; % valid frequency on 10th subcarrier, rest all zeros x2T = N*ifft(fftshift(x2F)); % time domain signal using ifft() % comparing the signals diff = x2T – x1T; err = diff*diff’/length(diff)
Plotting the frequency response of a filter
Consider a filter with the a sinc() shaped impulse response. The Matlab code for plotting the frequency response is as follows:
% impulse response of a sinc() filter
hT = sinc([-20:20]/3); % consider sample at 30MHz sampling;
hF = fft(hT,1024); % 128 pt FFT
figure;
plot([-512:511]*30/1024,fftshift(abs(hF))) ;
xlabel('frequency, MHz')
ylabel('amplitude')
title('frequency response of sinc filter');
Hopefully, the post provides some insights on the query raised in the comp.dsp thread.
Related posts
- Polyphase filters for interpolation
- Zero-order hold and first-order hold based interpolation
- Transmit pulse shaping filter – rectangular and sinc (Nyquist)
- Example of Cascaded Integrator Comb filter in Matlab
- Raised cosine filter for transmit pulse shaping
D id you like this article? Make sure that you do not miss a new article by subscribing to RSS feed OR subscribing to e-mail newsletter. Note: Subscribing via e-mail entitles you to download the free e-Book on BER of BPSK/QPSK/16QAM/16PSK in AWGN.




{ 11 comments… read them below or add one }
I want to do program of radix4 ( loop) pls help me
@harikrishni: May I point you to the article by Richard Lyons on Computing Large DFTs Using Small FFTs will be helpful.
URI: http://www.dsprelated.com/showarticle/63.php
Hi
In the FFT example of SINC function, could you please explain how the 30MHz sampling is implemented in the following line?
hT = sinc([-20:20]/3); % consider sample at 30MHz sampling;
@Leyo: The concept of time between the samples in Matlab is notional. It can be anyvalue. I just chose to use 30MHz so as to show the spectral plots from -15MHz to +15MHz [-fs/2 to fs/2).
I had chosen as 300MHz, the spectral plot will have changed to -150MHz to +150MHz.
Hope this helps.
Hi
I need a small help in plotting frequency spectrum of signal. I have plotted the frequency spectrum of signal using fft in matlab but the plot shows 2 spectrum. Could you please explain why.
@anisha: If its a real signal, then we have spectrum at +ve and -ve components. For eg, if we try to plot the spectrum of cos(wt), we will see spectrum at -w and +w. Does that answer your query?
A small typo in line 6
instead of xt I think it is x1T
Thanks
@Ashok: Thanks, I corrected it
hi Krishna
i need to ask some basic questions
when we talk about ifft period,i.e 128,256…..are that subcarriers we are talking about?
how we define subcarriers spacings in matlab?
I could not really understand how to visualize an OFDM symbol in both time and frequency domain together,
@jahanzaib: My replies:
There are two aspects to consider –
fs – the sampling frequency of the ifft or fft
N – number of points
If we have an N point ifft running at sampling frequency of fs, then the subcarrier spacing is fs/N.
Typically in OFDM specifications, we the ifft size is equal to the maximum number of subcarriers which may be used. However, we do not use all the avaliable subcarriers.
Hi Krishna
i hope tht you are fine and doing good. i want to ask that why the output of fft i.e x1F is only at the 10th subcarrier?.
Thanking you in anticipation.