Data communication Part 4-Computer Networks-Lab Assignment, Exercises of Computer Networks

This lab assignment was submitted to Sir Nauman Shamim at Pakistan Institute of Engineering and Applied Sciences, Islamabad (PIEAS) for Computer Networks course. It includes: Band, Bandwidth, Data, Rate, Generating, Sine, Waves, Frequency, Signals, Subplot

Typology: Exercises

2011/2012

Uploaded on 07/08/2012

nademm
nademm ๐Ÿ‡ต๐Ÿ‡ฐ

5

(2)

4 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
๎˜ƒData Communication Labโ€04
Date:4/8/2010๎˜ƒ
Objective๎˜ƒ๎˜ƒ
The๎˜ƒobjective๎˜ƒof๎˜ƒthis๎˜ƒlab๎˜ƒis๎˜ƒto๎˜ƒunderstand๎˜ƒthe๎˜ƒconcepts๎˜ƒof๎˜ƒband,๎˜ƒbandwidth๎˜ƒand๎˜ƒdata๎˜ƒrate๎˜ƒ
Generating๎˜ƒSine๎˜ƒWaves๎˜ƒ
First,๎˜ƒwe๎˜ƒwill๎˜ƒdefine๎˜ƒa๎˜ƒsignal๎˜ƒwhich๎˜ƒis๎˜ƒa๎˜ƒ2๎˜ƒHz๎˜ƒsine๎˜ƒwave๎˜ƒover๎˜ƒthe๎˜ƒinterval๎˜ƒ[0,1]๎˜ƒseconds:๎˜ƒ
>> t = [0:.01:1]; % independent (time) variable
>> A = 8; % amplitude
>> f_1 = 2; % create a 2 Hz sine wave lasting 1 sec
>> s_1 = A*sin(2*pi*f_1*t);
A 4 Hz sinewave with the same amplitude will also be defined:
>> f_2 = 4; % create a 4 Hz sine wave lasting 1 sec
>> s_2 = A*sin(2*pi*f_2*t);
%plot the 2 Hz sine wave in the top panel๎˜ƒ๎˜ƒ
figure๎˜ƒ๎˜ƒ
subplot(3,1,1)๎˜ƒ๎˜ƒ
plot(t, s_1)๎˜ƒ๎˜ƒ
title('2 Hz sine wave')
ylabel('Amplitude')
%plot the 4 Hz sine wave in the middle panel
subplot(3,1,2)
plot(t, s_2)
title('4 Hz sine wave')
ylabel('Amplitude')
%plot the summed sine waves in the bottom panel
subplot(3,1,3)
plot(t, s_1+s_2)
title('Summed sine waves')
ylabel('Amplitude')
xlabel('Time (s)')
The result should look like the figure shown below.
docsity.com
pf3

Partial preview of the text

Download Data communication Part 4-Computer Networks-Lab Assignment and more Exercises Computer Networks in PDF only on Docsity!

Data Communication Lab โ€ 04

Date:4/8/ Objective

The objective of this lab is to understand the concepts of band, bandwidth and data rate

Generating Sine Waves

First, we will define a signal which is a 2 Hz sine wave over the interval [0,1] seconds:

t = [0:.01:1]; % independent (time) variable

A = 8; % amplitude

f_1 = 2; % create a 2 Hz sine wave lasting 1 sec

s_1 = Asin(2pif_1t);

A 4 Hz sinewave with the same amplitude will also be defined:

f_2 = 4; % create a 4 Hz sine wave lasting 1 sec

s_2 = Asin(2pif_2t);

%plot the 2 Hz sine wave in the top panel

figure

subplot(3,1,1)

plot(t, s_1)

title('2 Hz sine wave')

ylabel('Amplitude')

%plot the 4 Hz sine wave in the middle panel

subplot(3,1,2)

plot(t, s_2)

title('4 Hz sine wave')

ylabel('Amplitude')

%plot the summed sine waves in the bottom panel

subplot(3,1,3)

plot(t, s_1+s_2)

title('Summed sine waves')

ylabel('Amplitude')

xlabel('Time (s)')

The result should look like the figure shown below.

Exampleโ€ 02

In this example, we will generate sinwaves with odd integers for frequencies (1, 3, 5, 7, 9, 11) and

cumulatively sum them together. After each new sinewave is added to the others, the result is plotted in

its own subplot. To be explicit, a 1 Hz sinewave is generated and plotted. Then a 3 Hz sinewave is

generated, added to the 1 Hz sinewave and plotted. A 5 Hz sinewave is generated, added to the sum of

the 1st two signals and plotted, etc

%plot cumulatively summed sine waves with odd integer frequencies scaled by

1/f

t = 0:.001:1; % independent (time) variable

A = 1; % amplitude

f = 1:2:11; % odd frequencies

s = zeros(1,101); % empty 'signal' vector to start with

figure

% for each frequency, create the signal and add it into s(t)

for count=1:

s = s + Asin(2pif(count)t)/f(count);

subplot(6,1,count)

plot(t,s);

ylabel('Amplitude')

end

subplot(6,1,1)

title('Cumulatively summing sine waves')