<< Chapter < Page | Chapter >> Page > |
Often, however, there is no analytical expression for a signal; that is, there is no (known) equation that represents thevalue of the signal over time. Instead, the signal is defined by measurements of some physical process.For instance, the signal might be the waveform at the input to the receiver, the output ofa linear filter, or a sound waveform encoded as an MP3 file. In all these cases, it is not possibleto find the spectrum by calculating a Fourier transform since the signal is not known in analytical form.
Rather, the discrete Fourier transform (and its cousin,
the more rapidly computable fast Fourier transform, or FFT)can be used to find the spectrum or frequency content
of a measured signal. The M
atlab function
plotspec.m
,
which plots the spectrum of a signal, is available on the website.Its help file
You can view the help
file for the M
atlab function
xxx
by typing
help xxx
at the M
atlab prompt. If you get an error such as
xxx not
found
, then this means either that the function does not exist,
or that it needs to be moved into the same directory asthe M
atlab application.
If you don't know what the proper command to doa job is, then use
lookfor
. For instance,
to find the command that inverts a matrix, type
lookfor inverse
. You will find the desired command
inv
. notes
plotspec(x,Ts) plots the spectrum of x
Ts=time (in secs) between adjacent samples
The function
plotspec.m
is easy to use. For instance,
the spectrum of a square wave can be found using the following sequence:
f=10; % "frequency" of square wave
time=2; % length of timeTs=1/1000; % time interval between samples
t=Ts:Ts:time; % create a time vectorx=sign(cos(2*pi*f*t)); % square wave = sign of cos wave
plotspec(x,Ts) % call plotspec to draw spectrum
specsquare.m
plot the spectrum of a square wave
(download file)
The output of
specsquare.m
is shown
All code listings in
Software Receiver Design can be found on the website. We encourage you
to open M
atlab and explore the code as you read. in
[link] .
The top plot shows
time=2
seconds of a square wave
with
f=10
cycles per second. The bottom plot shows a
series of spikes that define the frequency content.In this case, the largest spike occurs at
Hz,
followed by smaller spikes at all the odd-integer multiples(i.e., at
,
,
, etc.).
Similarly, the spectrum of a noise signal can be calculated as
time=1; % length of time
Ts=1/10000; % time interval between samplesx=randn(1,time/Ts); % Ts points of noise for time seconds
plotspec(x,Ts) % call plotspec to draw spectrum
specnoise.m
plot the spectrum of a noise signal
(download file)
A typical run of
specnoise.m
is shown in
[link] . The top plot shows the noisy signal
as a function of time, while the bottom shows the magnitudespectrum. Because successive values of the noise
are generated independently, all frequencies are roughly equalin magnitude. Each run of
specnoise.m
produces
plots that are qualitatively similar, though the detailswill differ.
Notification Switch
Would you like to follow the 'Software receiver design' conversation and receive update notifications?