1st Sessional With Solution
-
Upload
tahir-iqbal -
Category
Documents
-
view
393 -
download
4
Transcript of 1st Sessional With Solution
FALL - 2011 TLC212 – PROGRAMMING IN TELECOM
Page 1 Iqra University Islamabad Campus, 5 Khayaban-e-Johar, Sector H-9, Islamabad | www.iqraisb.edu.pk
1st Midterm Examination
Course Code: TLC212 Course Title: PROGRAMMING IN TELECOM
Teacher’s Name: Muhammad Azam Total Marks: 50
Date & Time: 11:00 AM, Oct 20, 2011 Total Time: 90 Minutes
Student’s Name: Registration No:
Note: This is a programming based exam. You need to solve all the questions using Matlab and email your
code to me at [email protected] before 12:30. Your email title should be Your Name – Iqra ID – Mid1.
Question 01: [1 + 2 + 3 + 4 + 4 + 6 = 20 marks]
a) [1 marks] Create a row vector a_1 in which the first element is 2 and the last element is 37, with an
increment of 5 between the elements (2, 7, 12, … , 37).
Solution: a_1 = 2:5:37;
b) [2 marks] Create a column vector b_1 with 15 equally spaced elements in which the first element is
–21 and the last element is 12.
Solution: b_1 = linspace(-21,12,15);
c) [3 marks] Create the following matrix A by using vector notation for creating vectors with constant
spacing or the linspace command. Do not type individual elements explicitly.
Solution: A = [0:5:30; 600:-100:0; linspace(0,5,7)];
d) [4 marks] Using the zeros, ones, and eye Matlab commands, create the following arrays. Do
not type the individual elements directly.
Solution:
d_i = [ones(2,2); zeros(2,2)];
d_ii = [eye(3,3) ones(3,3)];
d_iii = [ones(2,4); zeros(1,4); ones(1,4)];
FALL - 2011 TLC212 – PROGRAMMING IN TELECOM
Page 2 Iqra University Islamabad Campus, 5 Khayaban-e-Johar, Sector H-9, Islamabad | www.iqraisb.edu.pk
e) [4 marks] Consider the matrix
i. [2 marks] Using relational operators to set all the terms of D, which are > 6 and < 0 equal to 0.
ii. [2 marks] Use logical fields to select the diagonal of this matrix and save it as a vector diag.
Solution:
D = [7 2 3 10; -2 -3 11 4; 8 1 6 5; 18 1 11 4];
D_i = D;
D_i(D>6 | D<0) = 0;
d_indices = logical(eye(4,4));
diag = D(d_indices);
f) [6 marks] Define the vector v = [2 4 6 8 10]. Then use the vector v in a mathematical
expression to create the following vectors. Do not type individual elements explicitly.
i. 𝑎 = [24 43 62 81 100]
ii. 𝑏 = 1
2 1
4 1
6 1
8
1
10
iii. 𝑐 = 1
22 1
42 1
62 1
82 1
102
iv. 𝑑 = [1 1 1 1 1]
Solution:
v = [2 4 6 8 10];
a = v.^(4:-1:0);
b = 1./v;
c = 1./(v.^2);
d = v.^0;
FALL - 2011 TLC212 – PROGRAMMING IN TELECOM
Page 3 Iqra University Islamabad Campus, 5 Khayaban-e-Johar, Sector H-9, Islamabad | www.iqraisb.edu.pk
Question 02: [5 + 7 + 6 = 18 marks]
a) [1 + 4 = 5 marks] Create the following matrix H
i. [2 marks] Create a 24 matrix G such that its first row includes the first two elements and the
last two elements of the first row of H, and the second row of G includes the second through
the fifth elements of the third row of H.
ii. [2 marks] Create a 33 matrix K such that the first, second, and third rows are the first, fourth,
and sixth columns of matrix H.
Solution:
H = [1.7:-.1:1.2 ; 22:2:32; 9:-1:4];
G = [H(1,[1 2 5 6]); H(3,2:5)];
K = H(:,[1 4 6])';
b) [1 + 6 = 7 marks] Create the following matrix B.
i. [2 marks] Create a six-element column vector named aa that contains the elements of the
second and fifth columns of B.
ii. [2 marks] Create a seven-element column vector named bb that contains elements 3 through 6
of the third row of B and the elements of the second column of B.
iii. [2 marks] Create a nine-element column vector named cc that contains the elements of
the second, fourth, and sixth columns of B.
Solution:
B = [18:-1:13; 12:-1:7; 6:-1:1];
aa = [B(:,2); B(:,5)];
bb = [B(3,3:6)'; B(:,2)];
cc = [B(:,2); B(:,4); B(:,6)];
c) [6 marks] For the triangle shown below, a = 200mm, b = 250mm, and c = 300mm. Define
a, b, and c as variables, and then:
i. [2 marks] Calculate angle 𝛾 (in degrees) by substituting the given variables in the equation
𝑐2 = 𝑎2 + 𝑏2 − 2𝑎𝑏 cos 𝛾 i.e. it is also called Law of Cosines.
ii. [2 marks] Calculate the radius 𝑟 of the circle inscribed in the triangle using the formula.
𝑟 = 1
2 𝑎 + 𝑏 − 𝑐 tan
1
2𝛾
iii. [2 marks] Calculate the radius 𝑟 of the circle inscribed in the triangle using the formula.
FALL - 2011 TLC212 – PROGRAMMING IN TELECOM
Page 4 Iqra University Islamabad Campus, 5 Khayaban-e-Johar, Sector H-9, Islamabad | www.iqraisb.edu.pk
𝑟 = 𝑠 𝑠−𝑎 𝑠−𝑏 (𝑠−𝑐)
𝑠, where 𝑠 =
1
2 𝑎 + 𝑏 + 𝑐
Solution:
a = .2; b = .25; c = .300;
gemma_rad = acos ((a^2 + b^2 - c^2) / (2*a*b) ); % part i
gemma_deg = gemma_rad*(180/pi); % radians to degrees
r = (1/2) * (a + b - c) * tan(gemma_rad/2); % part ii
s = (1/2) * (a + b + c); % part iii
r = sqrt(s*(s-a)*(s-b)*(s-c))/s;
FALL - 2011 TLC212 – PROGRAMMING IN TELECOM
Page 5 Iqra University Islamabad Campus, 5 Khayaban-e-Johar, Sector H-9, Islamabad | www.iqraisb.edu.pk
Question 03: [5 + 7 = 12 marks]
a) [5 marks] The current I (in amps) t seconds after closing the switch in the circuit shown is
𝐼 = 𝑉
𝑅(1 − 𝑒
− 𝑅
𝐿 𝑡
Given V = 120 volts, R = 240 ohms, and L = 0.5 henrys
i. [1 marks] Calculate the current I, 0.003 seconds after the switch is closed.
ii. [4 marks] Plot the current I verses time t graph with values of t ranging from 0 to 1 in steps of
0.05. Your plot should be displayed in green color and axis should be properly labeled.
Solution:
V = 120; R = 240; L = 0.5;
t = 0.003;
I_point003 = (V/R)*(1 - exp(-(R*t)/L));
t = 0:0.05:1;
I = (V/R)*(1 - exp(-(R*t)/L));
figure; plot(t,I,'g');
xlabel('time (sec)'); ylabel('Current (amperes)'); grid
b) [7 marks] Consider the diode circuit shown in the figure below.
The current 𝑖𝐷 and the voltage 𝑣𝐷 can be determined from the solution of the following system of
equations
𝑖𝐷 = 𝐼0 𝑒−𝑞𝑣𝐷𝑘𝑇 − 1 1
𝑖𝐷 =𝑣𝑆 − 𝑣𝐷
𝑅 (2)
where 𝐼0 = 10−14𝐴, 𝑉𝑆 = 1.5, and 𝑅 = 1200 and 𝑘𝑇
𝑞= 30 𝑚𝑉
The system can be solved numerically or graphically. The graphical solution is found by plotting 𝑖𝐷 as
a function of 𝑣𝐷 from both equations. The solution is the intersection of the two curves.
i. [3 marks] First make the plot of 𝑖𝐷 as a function of 𝑣𝐷 using equation (1). The values of 𝑣𝐷
should be ranging from 0 to 3 in steps of 0.1. Your plot should be displaced in red color with
solid line.
FALL - 2011 TLC212 – PROGRAMMING IN TELECOM
Page 6 Iqra University Islamabad Campus, 5 Khayaban-e-Johar, Sector H-9, Islamabad | www.iqraisb.edu.pk
ii. [3 marks] Then make the second plot (on top of first plot) of 𝑖𝐷 as a function of 𝑣𝐷 using
equation (2). Use the same range for 𝑣𝐷 described in (a). Your plot should be displayed in black
color with dotted line.
iii. [1 marks] Find the solution by spotting the intersection of the two plots.
Solution:
I0 = 10^-14; vS = 1.5; R= 1200; kT_q = 30;
vD = 0:.1:3;
iD1 = I0 * ( exp(-vD/kT_q) -1 );
figure; plot(vD, iD1, 'r');
iD2 = (vS - vD)/R;
hold on; plot(vD, iD2, 'k:'); grid
% Solution is iD = 0 for vD = 1.5 (the point of
intersection)