You are on page 1of 10

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING


EXPERIMENT NO: 1

Lab Title Introduction to MATLAB


Student Name: Muhammad Awais Badar Reg. No: 190469

Objective: To Learn about the LTI model and learn the basics of MATLAB
LAB ASSESSMENT:
Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)

Ability to Conduct
Experiment

Ability to assimilate the


results

Effective use of lab


equipment and follows
the lab safety rules

Total Marks: Obtained Marks:


LAB REPORT ASSESSMENT:
Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:


Date: Signature:
Lab Report #01
Introduction to MATLAB

Course: Control Systems Lab

Name: Muhammad Awais Badar

Roll No:190469

Section: Beep - A

Semester: 6th

Submitted to: Mam Arooj Tariq


Objective:
To use the MATLAB to learn the basic command of the control system toolbox and to learn about
the LTI model
Software Required:
MATLAB
Task 1:
Use MATLAB to find P3, P4, and P5 in Prelab 1.

Code:

%controlsystem lab 1 all tasks


%labtask 1
clc
clear all
close all
p1=[1 7 2 9 10 12 15];
p2=[1 9 8 9 12 15 20];
% To find p3
p3=p1+p2
%To find p4
p4=p1-p2
%To find p5
p5=conv(p1,p2)

Output Result:

Discussion:

In this task, we have written the two vectors which are given and performed different operations on
it like addition, subtraction and multiplication which is convolution as shown in the result section.
Task 2:
Use only one MATLAB command to find P6 in Prelab 2.
Code:
%labtask 2
clc
clear all
close all
p6=poly([-7 -8 -3 -5 -9 -10])

Output Result:

Discussion:

In this task, we have given the roots or factors ad we have determined the coefficients of the
equation by using the poly command which is as shown in the output result. As poly is a command
which gives the coefficients of the polynomial through which polynomial equation can be found.
Task 3:
Use only two MATLAB commands to find G1(s) in Prelab 3a represented as a polynomial
divided by a polynomial.

Code:
%labtask 3
clc
clear all
close all
G1=zpk([-2 -3 -6 -8],[0 -7 -9 -10 -15],[20])
[num,den]=residue(-2 -3 -6 -8,0 -7 -9 -10 -15,20)
P1=tf([num],[den])

Output Result:

Discussion:

In this task, we have given the transfer function in the form of roots, so first we have written the
given function in the MATLAB by the zero, pole gain(z,p,k) command and then multiply the
numerators and denominators and then by using the tf command we have written the transfer
function in the form of the polynomial by a polynomial as shown in the result.
Task 4:
Use only two MATLAB commands to find G2(s) expressed as factors in the numerator
divided by factors in the denominator.

Code:

%labtask 4
clc
clear all
close all
G2=tf([1 17 99 223 140],[1 32 363 2092 5052 4320])
G=zpk(G2)

Output Result:

Discussion:

In this task we have to write the transfer function in the zero, pole gain form so we have given the
transfer function in zero, pole gain form and then by using the zpk form, we have written the
transfer function in z,p,k form.
Task 5:
Using various combinations of G1(s) and G2(s), find G3(s), G4(s), and Gs(s). Various
combinations implys mixing and matching G1(s) and G2(s) expressed as factors and
polynomials. For example, in finding G3(s), G1(s) can be expressed in factored form
and G2(s) can be expressed in polynomial form. Another combi- nation is G1(s)
and G2(s) both expressed as polynomials. Still another combination is G1(s)and G2(s)
both expressed in factored form.

Code:
%labtask 5
clc
clear all
close all
G1=zpk([-2 -3 -6 -8],[0 -7 -9 -10 -15],[20]);
G2=tf([1 17 99 223 140],[1 32 363 2092 5052
4320]);
G3=G1+G2
G=tf(G3)
G4=G1-G2
G=tf(G4)
G5=G1*G2
G=tf(G5)

Output Result:
Discussion:

In this task 5 we have to use the results of the previous tasks and then use their results I their creates
and create different function by using different commands like tf,zpk, etc which is highly helpful
in creating these tasks as shown in the output results.
Task 6:
Use MATLAB to evaluate the partial fraction expansions shown in Prelab 4.
Code:

%labtask 6
clc
clear all
close all
% for g6
num=[5 10];
den=[1 8 15];
[r,p,k]=residue(num,den)
%for g7
num=[5 10];
den=[1 6 9];
[r,p,k]=residue(num,den)
%for g8
num=[5 10];
den=[1 6 34];
[r,p,k]=residue(num,den)

Output Result:

For G6
For G7

For G8

Discussion:
In this task, we have given the transfer function and we have to convert them in partial fractions so we have
written the transfer functions in MATLAB in the form of the num and den form and then find it in the form
of the partial fraction by using the r,p k form.

Conclusion:
This lab is all about familiarization with the MATLAB basic commands which is usually an
easy way of representing the transfer function in different mathematical forms these
commands usually save our time of representing the function and these are different
commands like poly, residue, rpk, tf, etc. These commands are basics that usually help us to
determine the values of the transfer function and usually help us in finding out different
mechanical, electrical systems. These commands help us in determining different functions in
LTI models.

You might also like