0% found this document useful (0 votes)
66 views

Department of Electrical Engineering Communication Systems: LAB-1 Introduction To Matlab

The document provides instructions for Lab 1 on Introduction to MATLAB. It outlines objectives, equipment, theory, procedures, and exercises for students to perform. Key points covered include: 1) MATLAB is a software program used for data manipulation, visualization, calculations, linear algebra, and solving engineering problems using toolboxes. 2) Procedures demonstrate basic operations, matrices, matrix manipulation, initialization, plotting, and multiple plots. 3) Exercises include operations on complex numbers, multiple functions, Fourier series, and finding polynomial roots. Students are to write codes, results, and attach to the manual. 4) The goal is for students to learn MATLAB variables, matrices, and basic plots.

Uploaded by

john jo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Department of Electrical Engineering Communication Systems: LAB-1 Introduction To Matlab

The document provides instructions for Lab 1 on Introduction to MATLAB. It outlines objectives, equipment, theory, procedures, and exercises for students to perform. Key points covered include: 1) MATLAB is a software program used for data manipulation, visualization, calculations, linear algebra, and solving engineering problems using toolboxes. 2) Procedures demonstrate basic operations, matrices, matrix manipulation, initialization, plotting, and multiple plots. 3) Exercises include operations on complex numbers, multiple functions, Fourier series, and finding polynomial roots. Students are to write codes, results, and attach to the manual. 4) The goal is for students to learn MATLAB variables, matrices, and basic plots.

Uploaded by

john jo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Department of Electrical Engineering

Communication Systems

Course Instructor: Dr. Muhammad Mahboob Ur Rahman Dated: 07-09-2016

Lab Instructor: Waseem Abbas Semester: 7th

Lab Instructor: Sanan Ahmad Session: BSEE-13

Group:

LAB-1 Introduction to Matlab

Reg. No. Report LAB Viva


Name
Marks Performance Marks Total (15)
(5) (5) (5)

4|Page
Introduction to Matlab

1.1 Objective
To learn to create MATLAB variables, Matrixes and basic plots.

1.2 Equipment/Apparatus
1. Software: Matlab
1.3 Conduct of Lab
1. Students are required to perform this experiment using the equipment provided.
2. Students are required to work in groups specified by lab engineers.
3. Students are advised to seek help from the course instructor, lab engineers, assigned teaching
assistants (TA) and lab attendants.

1.4 Theory
MATLAB is a software program that allows you to do data manipulation and visualization, calculations,
math and programming. 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. In addition, in automatic control theory, statistics and digital signal processing
(Time-Series Analysis) one can use MATLAB. The following toolboxes make it useful in soft computing at
various industrial and scientific areas:

1. Neural Networks
2. Optimization
3. Genetic Algorithms
4. Wavelets
5. Fuzzy Logic
6. Control systems
7. Signal processing
8. Communication Systems
1.5 Procedure
Enter the following commands and note down the results

1.5.1 Basic operations


>>a=2*5+5/2

Result:

>>a=a*5

Result:

1.5.2 Matrix
>>a = [1 2 3; 4 5 6; 7 8 9]

Result:

5|Page
>>a = [1,2,3;4,5,6;7,8,9]

Result:

1.5.3 Manipulating Matrix


>>b=a %Transpose

Result:

The following matrix operations are available in MATLAB:


Table 0-1 Matrix operations

Function Task
+ Addition
- Subtraction
* Multiplication
^ Power
Transpose
\ Left Division
/ Right Division

1.5.4 Matrix Initialization and Addressing:


>>A= [1 2 3 4;5 6 7 8]

Result:

>>A( : , : )

Result:

>>A(1,2)

Result:

>>A(1, :)

Result:

>>A(: ,[1,3])

Result:

6|Page
1.5.5 Changing and deleting matrix elements:
>>A=1:5

Result:

>>A(2) = 6

Result:

>>A([1 3]) = 0

Result:

1.5.6 Element-by-element operations vs. Matrix Operations


Matrix multiplication has a special procedure, and it is different from simple element-to-element
multiplication. This is unlike addition operation, where two matrices cab be added by simple element by
element addition, this is adding corresponding elements of the two matrices in question. Thus, we have a
special set of operators that distinguish Matrix operations from element-by-element operations. When you
intend to perform matrix operation, you simply use, * for multiplication, / for division, ^ for exponentiation
and so on.

But if you intend to perform element-by-element operations, you have to use, .* for multiplication, ./
for division and .^ for exponentiation.

>>A= [2 3 4;5 6 7;2 1 0];

>>B= [1 2 3;5 6 2;0 0 5];

>>A*B

Result:

>>A.*B

Result:

1.5.7 Basic Plotting


The MATLAB command used to plot the graph is plot (x, y).
x= [1 2 3 4 5 6];
y= [3 -1 2 4 5 1];
plot (x, y)
Now try the following:
x = 0: pi/100: 2*pi;
y= sin (x);
plot (x, y)

1.5.8 Adding titles and axis labels


MATLAB enables you to add axis labels and titles. Using the code from the previous section, add x- and
y-axis labels.

7|Page
xlabel (x = 0:2\pi);
ylabel (sine of x);
title (Plot of the Sine Function)

1.5.9 Multiple data sets in one plot


These statements plot three plots related functions of x: y1=2 cos(x), y2=cos(x), and y3=0.5*cos (x) in
the interval 0 x 2
x= 0:pi/100:2*pi;
y1= 2*cos(x);
y2= cos (x);
y3= 0.5*cos (x);
plot (x, y1,x, y2, x, y3)
xlabel ('0 \leq x \leq 2\pi')
ylabel ('Cosine functions')
legend ('2*cos(x)', 'cos(x)', '0.5*cos(x)')
axis ([0 2*pi -3 3])
1.6 Exercise
Write the codes of following exercises. Print the codes and results with proper labeling. Attach it with the
manual

1. Given that x=-5+9i and y=6-2i, use MATLAB to show that x-y=1+7i, x*y= -12+64i and x/y= -1.2 + 1.1i
2. Use MATLAB to compute: 6(351.4) + 140.35
3. Use MATLAB to plot the functions y=4(6x+1) and z=5e0.3x 2x over the interval 0<x<1.5
4. Use MATLAB to plot function s= 2 sin (3t+2) + (5t+1) over the interval 0<t<5
5. Plot exp(-x) sin(8x) for 0 x 2
6. 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.
7. Define a 4x3 matrix with zeros everywhere except the first line that is filled with 1. Hint= use ones
and zeros command
8. Use MATLAB to find roots of 13x3 + 182x2 184x +2503 = 0 Hint= use roots command
1.7 Student Learning Outcomes
What you have learnt in the lab? Describe.

8|Page

You might also like