Control System Engineering: Lab Report 01

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

Control System Engineering

Lab Report 01
Introduction to MATLAB with control
system aspect

Name: - Zain Ul Abidin


Reg. #: - FA16-BEE-053
Class: - BEE-5B
Teacher: - Sir Aziz Ul Haq
Date: - March 14, 2019

Department of Electrical Engineering


COMSATS Institute of Information Technology
Abbottabad
Lab Task
Following are the two transfer functions. Plot the step and impulse response and
label properly in script as well as in Simulink.

01: - (s+1)/(s^2+2s+1)
MATLAB Code with Results
clc , clear all , close all
%% Method 01 using "tf" command
num = [1 1];
den = [1 2 1];
sys=tf(num,den)
impulse (sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system
G(s)=(s+1)/(s^2+2s+1)','fontweight','bold','fontsize',10)
legend('Impulse Response')
grid on
figure
step(sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=(s+1)/(s^2+2s+1))','fontweight','bold','fontsize',10)
legend('Step Response')
grid on;
%% Method 02 using "zpk" command
sys=zpk([-1],[-1 -1],1)
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')
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')
grid on;

%% Method 03 using "s=tf('s')" command


s=tf('s')
sys=(s+1)/(s^2+2*s+1)
impulse(sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system
G(s)=(s+1)/(s^2+2s+1))','fontweight','bold','fontsize',10)
legend('Impulse Response')
grid on
step(sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=(s+1)/(s^2+2s+1))','fontweight','bold','fontsize',10)
legend('Step Response')
grid on

Simulink Model
Using transfer function block
Block Diagram
Command window
plot(time,output)
grid on
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system G(s)=(s+1)/(s^2+2*s+1)','fontweight','bold','fontsize',10)
legend('Step Response')
Result

using zero/pole block


Block Diagram
Command window
plot(time,output)
grid on
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system G(s)=(s+1)/(s^2+2*s+1)','fontweight','bold','fontsize',10)
legend('Step Response')

Result

Analysis
In this task, we have given a signal “G(s)= (s+1)/(s^2+2s+1)”. We must plot the step and impulse
response of it. Using coding in MATLAB there are three different method i.e.,
1) Using “tf” command
2) Using “zpk” command
3) Using “s=tf(‘s’)” command
I have used all these commands to plot step & impulse response of above given function. In this
way, me must have same results in all. Above figures show there is no difference in results.
Next, we use Simulink to do same procedure (to plot step & impulse response). In this model we
use two different blocks i.e.,
1) Transfer function block
2) Zero/pole block

02: - 10/(s+1) (s+3) (s+5)


MATLAB Code with Results
clc , clear all , close all
%% Method 01 using "tf" command
num = [10];
den = [1 9 23 15]; % (s+1)(s+3)(s+5)= s^3+9*s^2+23*s+15
sys=tf(num,den)
impulse (sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system
G(s)=10/(s+1)(s+3)(s+5)','fontweight','bold','fontsize',10)
legend('Impulse Response')
grid on
figure
step(sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=10/(s+1)(s+3)(s+5','fontweight','bold','fontsize',10)
legend('Step Response')
grid on;

%% Method 02 using "zpk" command


sys=zpk([],[-1 -3 -5],10)
impulse (sys)% Impulse response
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system
G(s)=10/(s+1)(s+3)(s+5','fontweight','bold','fontsize',10)
legend('Impulse Response')
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)=10/(s+1)(s+3)(s+5','fontweight','bold','fontsize',10)
legend('Step Response')
grid on;

%% Method 03 using "s=tf('s')" command


s=tf('s')
sys=10/((s+1)*(s+3)*(s+5))
impulse(sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system
G(s)=10/(s+1)(s+3)(s+5','fontweight','bold','fontsize',10)
legend('Impulse Response')
grid on
figure
step(sys)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=10/(s+1)(s+3)(s+5)','fontweight','bold','fontsize',10)
legend('Step Response')
grid on
Simulink Model
Using Transfer Function
Block Diagram

Command window
plot(time, output)
grid on
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system G(s)=10/(s+1)(s+3)(s+5)','fontweight','bold','fontsize',10)
legend('Step Response')
Result

using zero/pole block


Block Diagram

Command window
plot(time,output)
grid on
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system G(s)=10/(s+1)(s+3)(s+5)','fontweight','bold','fontsize',10)
legend('Step Response')
Result

Analysis
In this task, we have given a signal “G(s)= 10/(s+1)(s+3)(s+5)”. We must plot the step and
impulse response of it. Using coding in MATLAB there are three different method i.e.,
4) Using “tf” command
5) Using “zpk” command
6) Using “s=tf(‘s’)” command
I have used all these commands to plot step & impulse response of above given function. In this
way, me must have same results in all. Above figures show there is no difference in results.
Next, we use Simulink to do same procedure (to plot step & impulse response). In this model we
use two different blocks i.e.,
3) Transfer function block
4) Zero/pole block

You might also like