Digital Signal Processing Reference
In-Depth Information
Step 4 Frequency axis For a sequence x [ k ] of length N with a sampling
frequency ω s , the fft function y = fft(x) produces the CTFT of x ( t )at N
equispaced points within the frequency interval [0, ω s ]. The resolution ω in the
frequency domain is, therefore, given by ω = ω s / ( N 1). After centering,
performed by the fftshift function, the limits of the interval are changed
to [ −ω s /2, ω s /2]. The M ATLAB commands to compute the appropriate values
for the ω -axis are given by
> dw = 400* pi/ 400;
> w = -400* pi/2:dw:400* pi/2; % calculates frequency
% axis;
> subplot(224); plot(w,abs(z)); % magnitude spectrum
The subplot of the CTFT is plotted in Fig. 5.21(d). By inspection, it is confirmed
that it does correspond to the CTFT pair in Eq. (5.81).
The phase spectrum of the CTFT can be plotted using the angle function.
For our example, the M ATLAB command to plot the angle is given by
> subplot(224); plot(w,angle(z));
% phase spectrum
The above command replaces the magnitude spectrum in subplot(224)
by the phase spectrum. For the given signal, x ( t ) = 4 cos(10 π t ), the phase
spectrum is zero for all frequencies ω . The M ATLAB code for calculating the
CTFT of a cosine wave is provided below in a function called myctft .
function [w,z] = myctft
% MYCTFT: computes CTFT of 4*cos(10*pi*t)
% Usage: [w,z] = myctft
% compute 4 cos(10*pi*t) in time domain
A = 4;
% amplitude of cosine wave
w0 = 10*pi;
% maximum frequency in signal
ws = 20*w0;
% sampling rate
Ts = 2*pi/ws;
% sampling interval
t = -1:Ts:1;
% define time instants
x = A*cos(w0*t);
% samples of cosine wave
% compute the CTFT
y = fft(x);
% fft computes CTFT
z = pi*Ts*y;
% scale the magnitude of y
z = fftshift(z);
% centre CTFT aboutw=0
% compute the frequency axis
w = -ws/2:ws/length(z):ws/2-ws/length(z);
% plots
subplot(211); plot(t,x) % CT plot of cos(w0*t)
subplot(212); plot(w,abs(z)) % CTFT plot of cos(w0*t)
% end
Search WWH ::




Custom Search