0% found this document useful (0 votes)
20 views9 pages

LAB1

Uploaded by

ammaradil817
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views9 pages

LAB1

Uploaded by

ammaradil817
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

CONTROL SYSTEM LABORATORY REPORT 1

Introduction to MATLAB with Control System Aspect

SUBJECT:
CONTROL SYSTEM

Group Members:
Muhammad Ammar Adil (FA20-EPE-056)
IHSAN KHAN (FA30-EPE-112)

Submitted to:
Mam Zainab

A P C
TOTAL MARKS
OBTAINED MARKS

1
CONTROL SYSTEM LABORATORY REPORT 1

Example#1

Statement of the Example


Consider a first-order transfer function G(s) = 1/(s+1). The impulse response and
step response function can be created by using following commands in script file.

Mat lab code:


clc
clear all
close all
sys=zpk([],[-1],1);
figure

impulse (sys)% Impulse response


xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Impulse Response',1)
grid on
figure

step(sys) % step response


xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Step Response',1)
grid on;
figure

t = 0:0.01:10;
u = sin(t);
y=lsim(sys,u,t);% Sinusoidal response
plot(t,y)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Sine Response for system G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Step Response',1)
grid on;
2
CONTROL SYSTEM LABORATORY REPORT 1

Figures:
Step Response for system G(s)=1/(s+1)
1
Step Response
0.9
0.8
0.7
Amplitude

0.6
0.5
0.4
0.3
0.2
0.1
0
0 1 2 3 4 5 6 7 8 9
Time (seconds)

Sine Response for system G(s)=1/(s+1)


0.8
Step Response
0.6

0.4
Amplitude

0.2

-0.2

-0.4

-0.6

-0.8
0 1 2 3 4 5 6 7 8 9 10
Time

3
CONTROL SYSTEM LABORATORY REPORT 1

Simulink:

Output

4
CONTROL SYSTEM LABORATORY REPORT 1

Tasks:
Statement of the Problem:
Following are the two transfer functions. Plot the step and impulse response and
label properly in script as well as in Simulink. 1. (s+1)/(s2+2s+1)
2. 10/(s+1)(s+3)(s+5).

Task:
Following are the two transfer functions. Plot the step and impulse response and
label properly in script as well as in Simulink. 1. (s+1)/(s2+2s+1)
MATLAB code:
clc
Num = [1 1];
Dnum = [1 2 1];
SYS =
tf(Num
Dnum);
impulse(
SYS);
grid on
xlabel('Time','fontweight','bold','fo
ntsize',9)
ylabel('Amplitude','fontweight','bo
ld','fontsize',9) title('Impulse
Response for system
G(s)=s+1/(s^2+2s+1)','fontweight','bold','fontsize',10)
step(SYS);
grid on
xlabel('Time','fontweight','bold','fontsize',9)

ylabel('Amplitude','fontweight','bold','fontsize',9)

Output

5
CONTROL SYSTEM LABORATORY REPORT 1

By using Simulink
Simulink Model of Step Response

Output:

Simulink Model of Impulse Response

6
CONTROL SYSTEM LABORATORY REPORT 1

Task2
Following are the two transfer functions. Plot the step and impulse response and
label properly in script as well as in Simulink.2. 10/(s+1)(s+3)(s+5).
MATLAB Code
clc
SYS = zpk([],[-1 -3 -5],41);
impulse(SYS);
grid on

xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
Figure
step(SYS);
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)

Output:

Simulink Model of Step Response

7
CONTROL SYSTEM LABORATORY REPORT 1
Output:

Simulink model

Conclusion
These tasks explains that how to plot the impulse response and step response in
MATLAB code and in Simulink .

8
CONTROL SYSTEM LABORATORY REPORT 1

You might also like