

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Date:4/8/ Objective
The objective of this lab is to understand the concepts of band, bandwidth and data rate
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);
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)')
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')