Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

UNIVERSITY OF ENGINEERING &

TECHNOLOGY MAIN CAMPUS, PESHAWAR.

LAB REPORT
[Subject: Control System]

Submitted by:
Rimsha Khan

Registration No:
17PWELE5059

Section: A

Submitted to:
Sir Babar Abbas

Department:
Electrical Power Engineering, University of engineering & technology
Peshawar, Main Campus.
LAB # 01

TITLE:

Introduction to MATLAB Basics.

SOFTWARE:

MATLAB

MATLAB CODE:

%calculation of complex numbers %


clear all
close all
clc
task1='Calculation of Complex Numbers'
a=2+3i
b=2-5i
sum=a+b
difference=a-b
product1=a.*b
product2=a*b
division1=a/b
division2=a\b
division3=a./b
division4=a.\b
x=5*pi
y=cos(x)
w=cos(x)+sin(x)
% Vector and Matrix %
task2=' Vector and Matrix '
x1=[1 1 1;4 4 4]
y1=[2 3 4; 5 5 5]
z=[x1 y1]
size=size(z)
x2=ones(1,3)
% Entrying Numeric Value %
task2=' Entrying Numeric Value '
y2=[4 5 9]-11
y3=rand(1,10)
x3=0:0.1:4
x4=[1 2 3; 3 2 1; 1 4 7]
y4=det(x4)
z1=x4'
% Mathmatical function %
task3='Mathmatical function'
z2=2*pi
z3=3*pi
w1=abs(z2)+abs(z3)
w2=cos(z2)/sin(z3)
% Plotting %
f=1000;
T=1/f;
t=0:T/100:5*T;
A=10;
X=A*sin(2*pi*f*t);
subplot(4,1,1)
A1=plot(t,X,'linewidth',2)
hold on
Y=A*cos(2*pi*f*t);
B1=plot(t,Y,'linewidth',2)
xlabel('Time')
ylabel('Amplitude')
grid on
grid minor
title('Waveform')
legend([A1,B1],'sin(t)','cos(t)');
axis([0,3*T,-10,10])
% Subplot %
subplot(4,1,2)
p1=plot(t,exp(-1000*t),'linewidth',2)
xlabel('Time')
ylabel('Amplitude')
grid on
grid minor
title('Waveform')
subplot(4,1,3)
p2=plot(t,Y,'linewidth',2)
xlabel('Time')
ylabel('Amplitude')
grid on
grid minor
title('Waveform')
subplot(4,1,4)
p3=plot(peaks)
title('Peaks')
T=tf([10 20],[1 11 31 21])
pzmap(T)
figure(1)
ltiview(T)
figure(2)
rlocus(T)
figure(3)
bode(T)
figure(4)
nyquist(T)
RESULT:
LAB 6

TITLE:

MATLAB Codes and Plots for Step and Impulse Responses of Antenna Azimuth
System Using Transfer Function

SOFTWARE:

MATLAB

MATLAB CODE:

clc
clear all
close all
% Task no: 1
% part a: ploynomial decalration and multiplication
P1=[5 7 -9 0 2]
P2= [ 1 -3 6 2 1]
P3=conv(P1,P2)
% part b: when polynomail is given in factor form then
s=tf('s');
F=((s+2)*(s+5)*(s+6))
P4=poly([-2 -5 -6])
% part c : finding roots of a polynomial #
roots(P4)
% TASK NO 2: Partial fraction expansion in Matlab:
s=tf('s');
G=(s^2+2*s+3)/((s+1)^3)
num=[ 0 1 2 3]
den=[ 1 3 3 1]
[r p k]=residue(num,den)
% TASK NO 3: find root locus plot and bode plot using transfer function
s=tf('s')
G=(s^2-4*s+20)/((s+2)*(s+4))
num=[1 -4 20];
den=poly([-2 -4]);
figure(1)
step(num,den)
sys=tf(num,den)
figure(2)
rlocus(sys)
figure(3)
bode(sys)
% TASK NO 3:
% ( Part b) :
% Step and impulse response using transfer function
s=tf('s')
G=(s^2-4*s+20)/((s+2)*(s+4))
num=[0.2083]
den=[1 1.71 0]
% Task no 4:
% Impulse response of load and motor of antenna
% azimuth system using transfer function:
num=[0 0.2083];
den=[1 1.71 0]
syst1=tf(num,den)
impulse(syst1)
xlabel('time')
ylabel('y(t)')
title('Step impulse by transfer function')
grid on;

RESULT:
LAB 7

TITLE:

State Space Representation Of SISO LTI System.

SOFTWARE:

MATLAB

MATLAB CODE:

clc
clear all
close all
A=[-101.71 -100;1 0];
B=[1 0]';
C=[0 20.83];
D=[0];
syst=ss(A,B,C,D)
figure(1)
step(syst)
xlabel('time')
ylabel('y(t)')
title('Step response by state space')
grid on
figure(2)
impulse(syst)
xlabel('time')
ylabel('y(t)')
title('Impulse response by SS')
grid on
t=0:0.05:10
A=[-1 -1;6.5 0];
B=[1 1;0 1];
C=[1 0;0 1];
D=[0];
figure(3)
step(A,B,C,D)
xlabel('time')
ylabel('y(t)')
title('Step response by SS')
grid on
t=0:0.05:10
A=[0 1 0;0 0 1;-10 -17 -8];
B=[0 0 0]';
C=[1 0 0];
D=[0];
y=initial(A,B,C,D,[2;1;0.5],t)
plot(t,y)
xlabel('time')
ylabel('y(t)')
title('Step response by state space')
grid on
figure(2)
impulse(syst)
xlabel('time')
ylabel('y(t)')
title('Impulse response by SS')
[num,den]=ss2tf([-101.71 -100;1 0],[1 0]',[0 20.83],0)

RESULT:
LAB 9

TITLE:

(A)To Obtain The Step Response For Transfer Function And State Space System In
Simulink

(B) Solution Of Differential Equation In MATLAB Simulink.

(C) Lag-Lead Compensator Design In Simulink.

SOFTWARE:

MATLAB

SIMULINK AND RESULT:

Lab task A:

Overdamp system
Critically damp system

Underdamp system:
Undamped system:
Comparison:

Step response in Simulink using transfer function


Step response in Simulink using state space representation
Solution of differential equation with initial condition using state space

Example: For the differential equation when subjected to initial condition

Obtain the output response y(t) subject to the initial condition

, ,

The state space representation of the system is obtained:


Lab task B: Solution of differential equation in Simulink:
Lab task 3: Design of PID Controller in Simulink:

Proportional term gain=Kp=200 , Kd=170 ,Ki=10


Design of Lead lag compensator in Simulink Transfer function

Lead compensator:

Lag compensator:

You might also like