This document provides an overview of Fourier analysis and computing Fourier coefficients using MATLAB. It discusses Fourier series representation of periodic signals as the sum of sines and cosines, and how Fourier obtained the coefficients by multiplying both sides of the equation by specific trigonometric functions and integrating over one period. Examples are provided to demonstrate computing and plotting the Fourier series representation of a signal up to a certain harmonic using MATLAB code. The document also discusses related topics like bandwidth requirements and limitations of transmission channels.
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
DSP_Fourier_160301.pptx
1. Beirut Arab University
Computer Engineering Program
Digital Signal Processing (COME
384)
Instructor: Prof. Dr. Hamed Nassar
Fourier Analysis with MATLAB
Textbook:
◦ V. Ingle and J. Proakis, Digital Signal Processing Using
MATLAB 3rd Ed, Cengage Learning, 2012
(First Lecture [this one]: A. Tanenbaum, D. Wetherall,
Computer Networks 5th, Prentice Hall, 2010 )
1
Dr. Hamed Nassar, Beirut Arab Univ
2. The Fourier Series
In some books the series uses only sin, but with a phase angle, and in
some other books the series uses complex exponentials (see last slide
Prof. H. Nassar, BAU
6. How Fourier obtained the Coefficients an
To obtain the coefficients, we use the following technique,
utilizing the above-mentioned identities.
Namely, we multiply the two sides of (2-1) by a certain
function and integrate both sides over the period T (Recall
that we deal with a periodic signal. But even if it is not
periodic, we consider the finite part given to us to be the
period.)
We carefully select the function such that only one of the 3
coefficients is retained.
Fourier ingeniously selected sin 2kft to recover ak. That is
because, for every value of k, if sin 2kft is multiplied by
both sides of (2-1), we get
Integral g(t) sin 2kft = 0 + ak T/2 + 0 , for k = 1, 2, 3, . .
.
Note that the middle term is actually: 0 + … + ak T/2 + … +
0 , as it is a summaion and the function is multiplied by
Prof. H. Nassar, BAU
7. How Fourier obtained the Coefficients
bn, c
The same idea applies to bn , but we multiply by cos 2kft.
Now, to obtain c, we just integrate the two sides of (2-1)
over one period T. This gives, Integral g(t) = T C/2 .
This means that C = 2/T Integral g(t). In general, the DC
component is always the average of the signal (by
inspect).
Here we notice that the DC component in (2-1) was written
C/2, rather than just C, for an aesthetic reason--- namely to
get 2/T as the coefficient in front of the integral just to be
consistent with those for an and bn.
At any rate, aside from aesthetics, the DC component in
the Fourier series is just the average of the function g(t),
i.e. the integral from 0 to T of g(t) divided by T, which is
basically the area under the curve of g(t) for one period T.
So, for the character U, for example, whose ASCII code is
55h, the area would be 0.5, and for the character ?=3F, it is
Prof. H. Nassar, BAU
8. Example: The letter “b”
Hint: If you get cos 2n pi equate to 1, and if sin 2n pi
equate to 0.
Prof. H. Nassar, BAU
9. A binary signal and its root-mean-square Fourier amplitudes (b)–(e) Successive
approximations to the original signal.
.
Prof. H. Nassar, BAU
10. Graphing in MATLAB
Example: Plot the sin t from t= 0 to 100, with
resolution=0.1.
t = 0: 0.1:100; %Generates pts on t axis from 0 to 100,
inc=0.01
plot(t, sin(t)); grid;
title('The letter b constructed from its Fourier Harmonics');
xlabel('time in sec'); ylabel('Amplitude in Volts‘)
Prof. H. Nassar, BAU
11. Plotting Two functions in the same
graph
Example: Plot u=cos(w)+w, v=cos(w)+sin(w), then both.
w=0:0.01:10;
>> u=cos(w)+w; v=cos(w)+sin(w);
plot(w,u, w, v); grid
Prof. H. Nassar, BAU
12. Graphing in a function in MATLAB: Beating
Between Tones
Example: Plot 3 cycles of the 2 harmonics: cos(8*t) +
cos(9*t)
>>h =inline('cos(8*t)+cos(9*t)');
x=0: pi/40: 6*pi; %res=1/240
plot(x, h(x)), grid
x=0: pi/40: 6*pi;%linespace
y=cos(8*x)+cos(9*x)
plot(x, y), grid
If you have heard two slightly mistuned musical
instruments playing pure tones whose frequencies were
close but not equal, you have sensed a beating
phenomenon in which you perceive a single pure tone
whose amplitude slowly varies periodically.
The single perceived tone, as shown, has a frequency that
Prof. H. Nassar, BAU
13. Bar graphs in Matlab
harmonics = [ 1 2 3 4 5 6 7 8 ];
bar(harmonics,'BarWidth',0.05);
Default bar width is = 0.8. If width is 1, the bars within a
group touch one another. Values > 1 produce overlapping
bars. set width less than 1. e.g. figure; bar(graph,0.4); For
better output (stems instead of bars) & to start at 0 use:
t=0:7;harmonics = [ 1 2 3 4 5 6 7 8 ]; stem(t, harmonics,
Prof. H. Nassar, BAU
14. The letter b: DC + 1st harmonic
Example: Plot 1st harmonic of b using MATLAB
t=0:0.01:1; %Vector representing time, 101 pieces
c=3.0/8; %Scalar
u1=1/pi*(cos(pi/4)-cos(3*pi/4)+cos(6*pi/4)-cos(7*pi/4))
*sin(2*pi*t);
v1=1/pi*(sin(3*pi/4)-sin(pi/4)+sin(7*pi/4)-sin(6*pi/4))
*cos(2*pi*t);
plot(t,c+u1+v1); grid
When we write the above code
in MATLAB we get ->
Note that we’ve taken period=T,
thus each t=x/T, but f=1/T, thus t=x
Prof. H. Nassar, BAU
15. Notes on the MATLAB code
Example: Plot 1st harmonic of b using MATLAB
t=0:0.01:1; %Vector representing time, 101 pieces
c=3.0/8; %Scalar
u1=1/pi*(cos(pi/4)-cos(3*pi/4)+cos(6*pi/4)-cos(7*pi/4))
*sin(2*pi*t);
v1=1/pi*(sin(3*pi/4)-sin(pi/4)+sin(7*pi/4)-sin(6*pi/4))
*cos(2*pi*t);
plot(t,c+u1+v1); grid
Since t is a vector (size 101), the expressions u1 are applied to
each element of it (and so is v1). So, we have what is like an
implicit loop.
plot takes 2 vectors, one for x and one for y. They have to be of
same size, as plot takes one element from each to determine
the 2 coordinates of the points to be plotted, 101 in our case.
Prof. H. Nassar, BAU
16. The letter b: DC + 1st harmonic+ 2nd
harmonic
Example: Plot the letter b using the 1st and 2nd harmonics.
t=0:0.01:1;
c=3.0/8;
u1=1/pi*(cos(pi/4)-cos(3*pi/4)+cos(6*pi/4)-cos(7*pi/4))
*sin(2*pi*t);
v1=1/pi*(sin(3*pi/4)-sin(pi/4)+sin(7*pi/4)-sin(6*pi/4))
*cos(2*pi*t);
u2=1/(2*pi)*(cos(2*pi/4)-cos(2*3*pi/4)+cos(2*6*pi/4)-
cos(2*7*pi/4)) *sin(2*2*pi*t);
v2=1/(2*pi)*(sin(2*3*pi/4)-sin(2*pi/4)+sin(2*7*pi/4)-
sin(2*6*pi/4)) *cos(2*2*pi*t);
plot(t,c+u1+v1+u2+v2); grid
Prof. H. Nassar, BAU
17. Output of: DC + 1st harmonic+ 2nd
harmonic
plot(t,c+u1+v1+u2+v2); grid
Note that u1, v1, u2, v2 are all vectors, whereas c is a
scalar=0.375.
When you add a scalar to a vector, the scalar is added to each
element of the vector.
So the result of adding the above 5 pieces, 1 scalar and 4
vectors, is a vector of size 101, which is plotted against the
Prof. H. Nassar, BAU
18. Finding an expression for the nth
harmonic
Since:
u2=1/(2*pi)*(cos(2*pi/4)-cos(2*3*pi/4)+cos(2*6*pi/4)-
cos(2*7*pi/4)) *sin(2*2*pi*t);
v2=1/(2*pi)*(sin(2*3*pi/4)-sin(2*pi/4)+sin(2*7*pi/4)-
sin(2*6*pi/4)) *cos(2*2*pi*t);
Then:
un=1/(n*pi)*(cos(n*pi/4)-cos(n*3*pi/4)+cos(n*6*pi/4)-
cos(n*7*pi/4)) *sin(n*2*pi*t);
vn=1/(n*pi)*(sin(n*3*pi/4)-sin(n*pi/4)+sin(n*7*pi/4)-
sin(n*6*pi/4)) *cos(n*2*pi*t);
The strategy now is implement a function for un (vn), which
takes vector t and scalar n and returns a vector un (vn).
Prof. H. Nassar, BAU
19. Script Fourier.m to plot letter b up to Nth
harmonic
%Fourier.m: plot letter b from its first N harmonics-Nassar
141007
t=0:0.005:1; %time vector. One period T sampled 201
times
c=3.0/8; %DC Coponent
un=zeros(1,201); %Create and initialize (preallocate) two 0
vecs
vn=un; %Both essential to guarntee emptyness befor
sum
N = input('Enter the highest harmonic number: ');
for n=1:N %Sum up to Nth harmonic
un=un+1/(n*pi)*(cos(n*pi/4)-cos(n*3*pi/4)+cos(n*6*pi/4)-
cos(n*7*pi/4)) *sin(n*2*pi*t);
vn=vn+1/(n*pi)*(sin(n*3*pi/4)-sin(n*pi/4)+sin(n*7*pi/4)-
sin(n*6*pi/4)) *cos(n*2*pi*t);
Prof. H. Nassar, BAU
20. Output of Script Fourier.m: to plot letter b up to 50th
harmonic
When the script is run (by typing Fourier at the command
window), it first prompts for N. When we enter N=50 we
get:
Prof. H. Nassar, BAU
21. Fourier2.m: improved Fourier script
%Fourier2.m: Improved plot of char b from its harmonics-Nassar
141007
t=0:0.005:1; %Time vector. One peirod T sampled 201
times
g=[zeros(1,25) ones(1,50) zeros(1,75) ones(1,25) zeros(1,26)];
c=3.0/8; %DC component
un=zeros(1,201); %Create and initialize (preallocate) two 0
vecs
vn=un; %Both essential to guarntee emptyness befor
sum
N = input('Enter the highest harmonic number: ');
for n=1:N %Sum up to Nth harmonic (below we add
vecs)
un=un+1/(n*pi)*(cos(n*pi/4)-cos(n*3*pi/4)+cos(n*6*pi/4)-cos(n*7*pi/4)) *sin(n*2*pi*t);
vn=vn+1/(n*pi)*(sin(n*3*pi/4)-sin(n*pi/4)+sin(n*7*pi/4)-sin(n*6*pi/4)) *cos(n*2*pi*t);
end Prof. H. Nassar, BAU
22. Fig **: Output of Fourier2.m: improved Fourier
script
Major improvement:
Showing the original
signal (green) along with
the 5 harmonics (blue)
(overlay)
Other improvements:
Axes labels
Graph title
Prof. H. Nassar, BAU
23. MATLAB Notes
The following three array-building methods are equivalent:
T= 1:2:7 OR t= [1:2:7] OR t= [1 3 5 7]
The first two are automatic and the last is manual.
Comparing the 1st and 2nd, one may think that the brackets
are redundant and thus should never be used. Well, they are
redundant here, but there comes a time when they have to be
used.
For long, complex arrays, such as the one for the signal (in
green), the first method is not useable, so we will be left with
the second.
g=[zeros(1,25) ones(1,50) zeros(1,75) ones(1,25)
zeros(1,26)];
Note that in g we would have had to enter 201 values
manually, if it were not for the functions: zeros and ones
which came to the rescue.
Each of the two places as many 0s or 1s as specified in the
Prof. H. Nassar, BAU
24. Bandwidth required for a given signal
Having seen that a signal contains (theoretically at least) an
infinite number of harmonics, does that mean that any signal
needs an infinite bandwidth? No. (Wikipediat “Actual signals
have finite duration and their frequency content, as defined
by the Fourier transform, has no upper bound.”)
In practice, only a finite number of harmonics, out of the
theoretical infinite, contribute significantly to the signal, the
rest insignificantly. So, the question now becomes where do
we draw the line between “significant” and “insignificant”?
A convention is to consider as insignificant any harmonic of
with energy below one half (1/2), professionally called falling
below 3dB.
Then the BW that such a signal needs for bona fide
transmission will be the frequency of the highest “significant”
harmonic.
Example: Suppose the highest signficant harmonic is the 10th
Prof. H. Nassar, BAU
25. Bandwidth of transmission channel
A signal needs a certain BW so it can be transmitted
without much distortion (or errors, for digital signals), but
the transmission channel may not provide that required
BW.
First, the transmission medium itself (e.g coax, TP, fiber)
has its own BW, determined by its natural and
manufactur properties.
Second, many channels are multiplexed on the same
medium, for higher efficiency and cost optimization, and
the channelling is typically made with filters which allow
only a certain band to go through.
The BW of a channel is defined as the width of the
frequency band transmitted without being “cutoff” by the
filter.
The cutoff frequency of a filter is never sharp. In
practice, the quoted BW is from 0 to the frequency at
which the energy of the harmonics coming out of the filter
Prof. H. Nassar, BAU
26. Bandwidth of transmission channel
Channelling lets more signals share a given region of
spectrum, improving the overall efficiency of the system.
For example, a phone coax trunk with BW 400 MHz can
carry 10000 phone calls simultaneously. (we place 1KHz
guard bands between calls to avoid cross talk) Using a
multiplexer, each phone signal (call) is shifted up to fit in
a special frequency band in the available 400 MHz.
Before shifting, a signal (whose frequency band is from 0
to 3 KHz) is called a baseband signal.
Three factors affect the BW requirement of a digital
signal obtained by sampling an analog one: the intended
transmission speed, the sampling rate, and the shape of
the analog signal (heavily fluctuating, steady, etc.). We
have no control on the last, but we do have on the first
two. This should be observed, else your signal may be
received erroneously. Namely, two procedures decrease
the BW required for transmission:Prof. H. Nassar, BAU
28. Graphing the amplitudes
If the bandwidth of the channel carrying the letter b is so low
that only the first 5 harmonics were transmitted, the letter b
would be received as in Fig. ** above. We do not care much
about how close to the transmitted signal the received signal is,
but care rather about whether the transmitted signal can be
recovered from the received.
We graphed earlier a signal synthesized from some of its
harmonics.
It should be noted that harmonics do not add to the signal
equally.
Recalling that one harmonic is made of two “pieces” : cos and
sin, we can compute the amplitude of the nth harmonic as
So, let us calculate and plot the first 10 harmonics of the
character b.
Prof. H. Nassar, BAU
2
2
n
n
n b
a
h
29. Graphing the amplitudes
%Fourier_Amp.m: Amplitudes of 15 first harmonics-Nassar 141007
x=0:15; %x axis vec, size =11. We use it to start plot at 0
amp=zeros(1,16);% Pre allocate vector for harmonic
amplitudes
amp(1)=3.0/8; %DC component
for n=1:15 %Obtain up to 15th harmonic
an=1/(n*pi)*(cos(n*pi/4)-cos(n*3*pi/4)+cos(n*6*pi/4)-
cos(n*7*pi/4));
bn=1/(n*pi)*(sin(n*3*pi/4)-sin(n*pi/4)+sin(n*7*pi/4)-
sin(n*6*pi/4));
amp(n+1)=sqrt(an^2+bn^2);
end
stem(x,amp,'LineWidth',2,'Color',[0.9 0 0.5]),
grid, xlabel('Harmonic Number'),
ylabel('Amplitude (V)'), Prof. H. Nassar, BAU
30. Graphing the amplitudes
Shown are
the amplitudes of
the 1st 15 harmonics
in the signal of ‘b’.
(15 are chosen
to get the same
graph as the textbook (Tannenbaum)).
The stem at 0 is the DC component.
We can see that the significant contributions are up to
the 6th harmonics. That is, if we use a channel of BW B
= 6f, where f=1/T is the fundamental frequency and T is
the character time = 8 bit time, then the signal will be
received good enough to be recovered by the receiver.
But note that the bit time=1/bit rate, b. So, we should
use b = 4/3 B.
For example, if we are using a phone line, we send at
Prof. H. Nassar, BAU
31. Bandwidth
BW is the width of the band of frequencies (the
frequency range) transmitted without being strongly
attenuated, with “strongly” typically taken >50%.
For transmission media, the bandwidth is naturally
limited by the physical properties of the medium, for
example, the material, thickness, and length of a wire
or fiber.
For channels, the bandwidth is artifitally limited by
filters. Filtering lets more signals share a given region
of spectrum, which improves the overall efficiency of
the system. For example, 802.11 WiFi channels are
allowed to use up to roughly 20 MHz. As another
example, traditional (analog) television channels
occupy 6 MHz each, on a wire or over the air.
Furthermore, a voice grade phone channel is typically 4
kHz.
Prof. H. Nassar, BAU
32. Baseband vs. passband
When we let two or more signals share the same
medium, assigning each a given bandwidth, then we
have to place these signals into successive bands of
frequencies, starting from some base frequency f0 , and
going upwards.
That is, the signals that run from f=0 up to the end
frequency fe, with bandwidth=fe, are shifted up in
frequency to reside in its intended band (channel).
The signal before the shift is called baseband signal,
and after is called passband signal.
Prof. H. Nassar, BAU
33. Relationship bet: Bandwidth (Hz), Data Rate (bps), and Fourier
Harmonics
For digital transmission, the goal always is to receive a
signal with just enough fidelity to reconstruct the bits that
were sent.
For the character “b”, we can do this by sending up to the
8th harmonic, as shown below, so it is wasteful to use
more BW.
The 8th harmonic is of frequency 8f, where f is the
fundamental frequency, which is determined by the data
rate, measured in bps as follows. If data rate is b bps,
then period T (=character time = 8 bit times) = 8/b s,
hence f = 1/T = b/8 Hz.
It is our job after finding the highest harmonic n needed
for accurate recovery of the transmitted signal at the
receiving end, to make sure that the BW required to
accommodate harmonics up to the nth n f <= B, the
channel’s BW.
Prof. H. Nassar, BAU
34. How many harmonics are enough to reconstruct the
original signal
Let B (Hz) be the BW of a given channel.
The question now: what is the bit rate, b (bps), on such a
channel, so that a character (8 bits) arriving at the
receiving end of the channel can be recovered.
Bit time = 1/ b sec
Then, Character time is T = 8/b sec
Then, the fundamental (Fourier) frequency of the
character signal is f = 1/T = b/8 Hz
Since channel’s BW = B Hz, then the number of the
highest harmonic to be passed by this channel is n = B/f =
8 B/b.
Typically, B is imposed, so the variables are n and b,
which as we see from the Eq: if one increases the other
has to decrease.
Ex: A voice-grade phone line, has bandwidth B=3kHz.
Find the highest harmonic the line will allow if we transmit
Prof. H. Nassar, BAU
35. How many bps can be transmitted over a channel of
BW=B Hz
The table below shows the number of harmonics of an 8-bit
character signal that a channel of BW B = 3000 Hz can
transmit, for different data rates b bps.
The table is obtained
From the Eqn: n = B/f = 8 B/b
It is clear that sending at 9600 bps will transform only up to
the 2nd harmonic. That is, in the graph below, the signal
above will be received like the one below, making accurate
reception of the original bit stream tricky.
Prof. H. Nassar, BAU
36. How many bps can be transmitted over a channel of
BW=B Hz
It should be obvious that at data rates much higher than
38.4 kbps, there is no hope at all for binary signals,
even if the transmission facility is completely noiseless.
However, coding schemes that make use of several
(i.e. not binary) voltage levels do exist and can achieve
higher data rates.
In conclusion, limiting the bandwidth curbs the data
rate, even for perfect channels (those without noise).
Prof. H. Nassar, BAU
37. Two meanings for Bandwidth: Electrical B Hz &
Computer b bps
There is much confusion about bandwidth because it
means different things to electrical engineers and to
computer engineers.
To electrical engineers, (analog) bandwidth is (as we have
described above) a quantity measured in Hz.
To computer engineers, (digital) bandwidth is the maximum
data rate of a channel, a quantity measured in bps
(bits/sec).
It should be clear from the context whether we mean
analog bandwidth (Hz) or digital bandwidth (bps).
The data rate is the end result of using the analog
bandwidth of a physical channel for digital transmission,
and the two are related, as we discuss next.
Prof. H. Nassar, BAU
38. Maximum Data Rate: 1-Noiseless channel (Nyquist
Theorem)
Nowadays, it is common to transmit analog signals
digitally, as data, by sampling the signal K times per
second.
Henry Nyquist is credited for 2 results obtained around
1924.
First result (Analog signal transmitted in a noiseless
channel): If an analog signal is transmitted through a
channel of bandwidth B Hz (B determined via a low-pass
filter), it can be completely reconstructed at the receiver
by making only 2B samples/s.
For example, if a received sound wave is not a pure sine
wave but a linear superposition of sine waves
(harmonics) with the highest having a frequency f, Nyquist
says that to reconstruct it, it is sufficient to sample it at a
frequency 2f. Sampling at a higher frequency is of no
value since the higher frequencies that such sampling
could detect were filtered out by the channel (by the filter
Prof. H. Nassar, BAU
39. Maximum Data Rate: 1-Noiseless channel (Nyquist
Theorem)
Second result (Digital signal of V symbols – levels –
transmitted in a noiseless channel): He showed that the
max symbol rate (also, max sampling rate at both
transmitter & receiver) in a noiseless channel of bandwidth
B Hz is
maximum symbol (can also go ‘sample’) rate = 2B sps
Each symbol can carry one or more bits, depending on the
number of symbols V=2, 3, … Specifically, each symbol
can encode log2 V bits. Thus, we can extend the above
formula to obtain the maximum data rate (MDR) in bps as
follows. maximum data rate = 2B log2 V bps
Ex.: Find MDR for a noiseless 3-kHz channel, assuming
V=2
Maximum data rate = 2 x 3000 log2 2 = 6000 bps
We can relate the two results as follows. A noiseless
channel of bandwidth B Hz, allows harmonics up to 2 B to
pass. This number of harmonics is produced (recovered)
Prof. H. Nassar, BAU2
40. Relation of the signal shape to its required bandwidth
Here we will consider two characters whose ASCII signals
are radically different in shape: the characters U and ?
U=55h=01010101b , which means a maximum of
fluctuations and ? = 3F = 00111111b which means lower
fluctuations.
The analysis of U gives:
an=1/(n*pi)*(cos(n*pi/4)-cos(n*2*pi/4)+cos(n*3*pi/4)-
cos(n*4*pi/4)+cos(5*n*pi/4)-cos(n*6*pi/4)+cos(n*7*pi/4)-cos(n*8*pi/4))
(Coeff of sin(n*2*pi*t) )
bn= 1/(n*pi)*(sin(n*2*pi/4)-sin(n*pi/4)+sin(n*4*pi/4)-
sin(n*3*pi/4)+sin(n*6*pi/4)-sin(5*n*pi/4)+sin(n*8*pi/4)-sin(n*7*pi/4))
(Coeff of cos(n*2*pi*w))
c=0.5 (DC Component. Average obtained by inspection)
Now, we would like to draw the amplitudes of, say, the
first 40 harmonics to know where the energy is
concentrated, but first we will draw the synthesized signal
Prof. H. Nassar, BAU
41. Script to sketch char U synthesized from its first 40
harmonics
%Fourier2_U.m: Synthesis of 40 harmonics of U=55h-Nassar 141007
t=0:0.005:1; %Time vector. One peirod T sampled 201 times
g=[zeros(1,25) ones(1,25) zeros(1,25) ones(1,25) zeros(1,25)
ones(1,25) zeros(1,25) ones(1,26)];
c=0.5; %DC component
un=zeros(1,201); %Create and initialize (preallocate) two 0 vecs
vn=un; %Both essential to guarntee emptyness befor sum
N = 40;
for n=1:N %Sum up to Nth harmonic
un=un+1/(n*pi)*(cos(n*pi/4)-cos(n*2*pi/4)+cos(n*3*pi/4)-
cos(n*4*pi/4)+cos(5*n*pi/4)-cos(n*6*pi/4)+cos(n*7*pi/4)-cos(n*8*pi/4))
*sin(n*2*pi*t);
vn=vn+1/(n*pi)*(sin(n*2*pi/4)-sin(n*pi/4)+sin(n*4*pi/4)-
sin(n*3*pi/4)+sin(n*6*pi/4)-sin(5*n*pi/4)+sin(n*8*pi/4)-sin(n*7*pi/4))
*cos(n*2*pi*t);
end
plot(t,c+un+vn,t,g), axis equal, axis([0 1 -0.2 1.2]),
grid, xlabel('time (s)'),
Prof. H. Nassar, BAU
42. Output of Script to sketch char U from its first 40
harmonics
Recalling that ?=3F=001111b, and given that 1 bit
time=0.125s, the sketch below testifies that the analysis is
correct.
We will repeat this for the char
‘?’ on the next slide.
We note the extending glitches
at the edge of each bit, called
“Gibbs horns”, which arise due to
the discontinuities, noting that Prof. H. Nassar, BAU
43. Script to sketch char ? synthesized from its first 40
harmonics
%Fourier2_QM.m: plot N harmonics of Char ?=3Fh-Nassar
141007
t=0:0.005:1; %Time vector. One peirod T sampled 201
times
g=[zeros(1,50) ones(1,151)];
c=3.0/4; %DC component, by inspection(6 1's, 2 0's)
un=zeros(1,length(t)); %Create & initialize (preallocate) two 0
vecs
vn=un; %Both essential to guarntee emptyness befor
sum
N = 40;
for n=1:N %Sum up to Nth harmonic
un=un+1/(n*pi)*(cos(2*n*pi/4)-cos(n*8*pi/4))*sin(n*2*pi*t);
vn=vn+1/(n*pi)*(sin(n*8*pi/4)-sin(n*2*pi/4))*cos(n*2*pi*t);
end
plot(t,c+un+vn,t,g), axis equal, axis([0 1 -0.2 1.2]),
Prof. H. Nassar, BAU
44. Output of Script to sketch char ? from its first 40
harmonics
Recalling that ?=3F=001111b, and given that 1 bit
time=0.125s, the sketch below testifies that the analysis is
correct.
We will repeat this for the char
‘?’ on the next slide.
Prof. H. Nassar, BAU
45. Script to calculate & plot amplitudes of first 40 harmonics
of char U
%Fourier_Amp_U.m: Plot amps of first 40 harmonics of U-Nassar
141016
x=0:40; %x coordinates. Starting at 0 lets us sketch DC at 0,
%since the first index of amp is 1, as is the case with MTLB vectors
amp=zeros(1,41);% Pre allocate vector for harmonic amplitudes
%Note that we'll plot amp(1) at x=0, amp(2) at x=1, and so on.
amp(1)=0.5; %DC component
for n=1:40 %Calculate up to 40th harmonic
an=1/(n*pi)*(cos(n*pi/4)-cos(n*2*pi/4)+cos(n*3*pi/4)-
cos(n*4*pi/4)+cos(5*n*pi/4)-cos(n*6*pi/4)+cos(n*7*pi/4)-
cos(n*8*pi/4));
bn=1/(n*pi)*(sin(n*2*pi/4)-sin(n*pi/4)+sin(n*4*pi/4)-
sin(n*3*pi/4)+sin(n*6*pi/4)-sin(5*n*pi/4)+sin(n*8*pi/4)-sin(n*7*pi/4));
amp(n+1)=sqrt(an^2+bn^2);
end
stem(x,amp,'LineWidth',2,'Color',[0.9 0 0.5]),
grid, xlabel('Harmonic No. (=multiple of fundamental frequency)'),
ylabel('Amplitude (V)'), Prof. H. Nassar, BAU
46. Script to calculate & plot amplitudes of first 40 harmonics
of char ?
%Fourier_Amp_QM.m: Plot amps of first 40 harmonics of U-Nassar
141016
x=0:40; %x axis. We start at 0 so we can plot DC there
amp=zeros(1,41);% Pre allocate vector for harmonic amplitudes
%Note that we'll plot amp(1) at x=0, amp(2) at x=1, and so on.
amp(1)=0.75; %DC component
for n=1:40 %Sum up to Nth harmonic
an=1/(n*pi)*(cos(2*n*pi/4)-cos(n*8*pi/4));
bn=1/(n*pi)*(sin(n*8*pi/4)-sin(n*2*pi/4));
amp(n+1)=sqrt(an^2+bn^2);
end
stem(x,amp,'LineWidth',2,'Color',[.9 0 .5]),
grid, xlabel(‘Harmonic No. (=multiple of fundamental frequency)'),
ylabel('Amplitude (V)'),
title('Amplitudes for first 40 harmonics of char ?=3F')
Prof. H. Nassar, BAU
47. Plot of amplitudes of first 40 harmonics for char ? = 3F
Once again, if we consider amplitudes below 0.1 to be
insignificant, then, as we see, the signal of char ? needs
BW=6 F, where F is the fundamental frequency
=1/character time.= b /8. Prof. H. Nassar, BAU
48. Plot of amplitudes of first 40 harmonics for char
U=55h
Once again, if we consider amplitudes below 0.1 to be
insignificant, then, as we see, the signal of char U needs
BW=28 F, much larger than that of char ? (6 F). The
reason is clearly the more fluctuations here (almost once
Prof. H. Nassar, BAU
49. FourierAnimation2.m: Animation of first N harmonics of
char b
clear all; clf; clc; t=0:0.005:1; %Time axis, sampled 201 times
g=[zeros(1,25) ones(1,50) zeros(1,75) ones(1,25) zeros(1,26)]; % Original Signal
N = input('Enter number of harmonics to sketch: ');
%2) Amplitudes of DC + first N harmonics
x=0:N; amp=zeros(1,N+1);% Pre allocate vector for harmonic amplitudes
amp(1)=3.0/8; %DC component
% Synthesized signal from its DC + first N harmonics
c=3.0/8; %DC component
un=zeros(1,length(t)); vn=un; %Create and initialize (preallocate) two 0 vecs, must be
empty
for n=1:N
an=1/(n*pi)*(cos(n*pi/4)-cos(n*3*pi/4)+cos(n*6*pi/4)-cos(n*7*pi/4));
bn=1/(n*pi)*(sin(n*3*pi/4)-sin(n*pi/4)+sin(n*7*pi/4)-sin(n*6*pi/4));
amp(n+1)=sqrt(an^2+bn^2);
un=un+an *sin(n*2*pi*t); %Note an and bn are scalars
vn=vn+bn*cos(n*2*pi*t); %But un and vn are scalars
subplot(2,1,2),plot(t,c+un+vn,t,g,'LineWidth',2),grid
title('Signal of char b & its synthesis from first N harmonics')
subplot(2,1,1),stem(x,amp,'LineWidth',2,'Color',[1 0 0]),grid
title('Amplitudes for first N harmonics of char b=61h')
pause(2.0);
Prof. H. Nassar, BAU
50. Maximum Data Rate: 1I-Noisy channel (Shanon
Theorem)
Nyquist considered only noiseless channels.
In 1948, Claude Shannon extended Nyquist’s to the case
of a channel subject to random (i.e. thermodynamic) noise.
The amount of noise is measured by the ratio of the signal
power S to the noise power N, called the SNR (Signal-to-
Noise Ratio).
This ration is expressed on a log scale as SNR = 10 log10
S/N because it can vary over a tremendous range.
The units of SNR are called decibels (dB), with ‘‘deci’’
meaning 1/10. S/N = 10 (SNR/10) .
Ex: S/N=10 is SNR=10 dB, S/N=100 is 20 dB, S/N=1000 is 30
dB.
Manufacturers of stereo amplifiers often characterize the
bandwidth (frequency range) over which their products are
linear by giving the 3-dB frequency on each end. These
are the points at which the amplification factor has been
approximately halved (because 10 log100.5 ∼ −3).
Prof. H. Nassar, BAU
51. Maximum Data Rate: 1I-Noisy channel (Shanon
Theorem)
Shannon’s major result is that the maximum data rate
or capacity of a noisy channel whose bandwidth is B Hz
and whose signal over noise ratio is S/N, is given by:
maximum data rate = B log2 (1 + S/N) bps
This tells us the best capacities that real channels can
have.
Example: ADSL (Asymmetric Digital Subscriber Line),
which provides Internet access over normal telephone
lines, uses a bandwidth of around 1 MHz.
The SNR depends strongly on the distance of the home
from the telephone exchange
Example: Typically, SNR =40 dB for phone lines of 1 to
2 km.
Such a line can never transmit much more than 13
Mbps, no matter how many or how few signal levels are
used and no matter how often or how infrequently
Prof. H. Nassar, BAU