Communication System Lab Manual: Department of Telecom Engineering University of Engineering and Technology Taxila
Communication System Lab Manual: Department of Telecom Engineering University of Engineering and Technology Taxila
LAB MANUAL
INTRODUCTION TO MATLAB
Objectives:
Pre-lab theory:
What is MATLAB?
MATLAB is a software program that allows you to do data manipulation and visualization, calculations,
math and programming. It can be used to do very simple as well as very sophisticated tasks. It
can solve large systems of equations efficiently and it is therefore useful for solving differential
equations and optimization problems. It also provides excellent means for data visualization and has
symbolic capabilities. Whilst simple problems can be solved interactively with MATLAB, its real
power shows when given calculations that are cumbersome or extremely repetitive to do by hand!
MATLAB is recognized as the interactive program for numerical linear algebra and matrix
computation. In industries, MATLAB is used for research and to solve practical engineering and
mathematical problems. Also, in automatic control theory, statistics and digital signal processing (Time-
Series Analysis) one can use MATLAB. The following tool boxes make it useful in soft computing at
various industrial and scientific areas:
(i) Neural Networks (ii) Optimization (iii) Genetic Algorithms (iv) Wavelets (v) Fuzzy Logic
(vi) Control systems (vi) Signal processing (vii) Communication Systems
Starting MATLAB
After logging into your account, you can enter MATLAB by double-clicking on the MATLAB shortcut
icon on the Window. After starting MATLAB, the MATLAB Desktop will appear. The default
three-part window looks similar to the figure below. The Desktop is also known as an Integrated
Development Environment (IDE). Clicking the Start button in the lower left-hand corner will display
a list of MATLAB tools, shortcuts, and documentation.
𝟏 𝟐
1. Given that x=-5+9i and y=6-2i, Z=[ ] use MATLAB find the following
𝟑 𝟏 + 𝟐𝒊
A. x+y
B. x-y
C. xy
D. x/y
E. transpose of Z
F. inverse of Z
Solution:
Simple mathematical operations can be performed by following code:
x=-5+9i;
y=6-2i;
a=x+y;
b=x-y;
c=x*y;
d=x/y;
e=Z’
f=inv(Z)
display(a)
display(b)
display(c)
display(d)
3. Define a 4x3 matrix with zeros everywhere except the first line that is filled with 1. Hint= use
ones and zeros command
Solution:
First we define 4x3 matrix then make it null matrix by replacing the rows and columns with zero. Then
using the same command for the replacement of first row from zero to one. Code is given below:
clc
clear all
close all
syms m;
matrix=[2,4,3;24,3,4;6,5,4;7,4,3];
display(matrix);
matrix(:,:)=0;
display (matrix);
matrix([1],:)=1;
display(matrix);
It displays the following result:
First matrix is matrix which we introduce, second one is null matrix and third one is required matrix.
matrix =
2 4 3
4 3 4
6 5 4
1 1 1
0 0 0
0 0 0
0 0 0
clc
clear all
close all
syms xyz;
A=[6 -4 8; -5 -3 7; 14 9 -5];
%X=[x;y;z];
B=[112;75;-67];
C=1./A;
X=C*B;
display(X);
Result that we get from above code is as follows:
X=
-8.4583
-56.9714
29.7333
5. Use MATLAB to find roots of 13x3 + 182x2 – 184x +2503 = 0
Solution:
To find the rootes of equation we just make its matrix and then apply command of ‘roots()’ which gives
roots in matrix form. Code for above equation is:
clc
clear all
close all
syms x;
A=[13 182 -184 2503];
r=roots(A);
display(r);
LAB 01-B
INTRODUCTION TO PLOTTING COMMAND ON MATLAB
Objectives:
Pre-lab theory:
MATLAB is very useful for making scientific and engineering plots. You can create plots of known,
analytical functions, you can plot data from other sources such as experimental measurements, and you
can analyze data, perhaps by fitting it to a curve, and then plot a comparison. MATLAB also has powerful
built-in routines for drawing contour and three-dimensional surface plots.
Two-dimensional line and symbol plots are created with the plot command. In its simplest form plot takes
two arguments
where xdata and ydata are vectors containing the data. Note that xdata and ydata must be the same length
and both must be the same type, i.e., both must be either row or column vectors. Additional arguments to
the plot command provide other options including the ability to plot multiple data sets, and a choice of
colors, symbols.
1. Use MATLAB to plot the functions y=4√(6x+1) and z=5e0.3x – 2x over the interval 0<x<1.5
Solution:
Code for plot of above two functions is:
clc
clear all
x=0:0.1:1.5;
y=4*sqrt(6*x+1);
z=5*exp(0.3*x)-2*x;
plot(x,y,'r');
hold on;
plot(x,z,'b');
2. Use MATLAB to plot function s= 2 sin (3t+2) + √(5t+1) over the interval 0<t<5.
Solution:
Code for above function is:
clc
clear all
close all
symst;
t=0:0.1:5;
s=2*sin(3*t+2)+sqrt(5*t+1);
plot(t,s);
xlabel('t');ylabel('s=2sin(3t+2)+?(5t+1)');
gtext('s=2sin(3t+2)+?(5t+1)');
title('Q4');
It gives the graph:
4. Plot the function y= (4/Π) [(sin x) + (sin 3x)/3 + (sin 5x)/5 + (sin7x)/7] over the interval –Π<x<Π.
These are the first four terms of the Fourier Series representation of a square wave.
Solution:
Code for this function is as follows:
clc
clear all
close all
syms x;
x=-pi:0.1*pi:pi;
y=(4/pi)*[sin(x)+(sin(3*x)/3)+(sin(5*x)/5)+(sin(7*x)/7)];
plot(x,y,'r');
title('Q6');
xlabel('Pi');ylabel('y=(4/pi)*[sin(x)+(sin(3*x)/3)+(sin(5*x)/5)+(sin(7*x)/7)]');