lab1 wednesday(2pm) azaan azeem
TRANSCRIPT
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
1/14
Azaan Azeem2017-10-0088Feedback and Control System Lab27/01/2016
LAB1
EXERCISE 1:
clc;clear all;close all% Part 1subplot(4,2,1);num1 = [1 5 6];den1 = [1 9 12];y1 = tf(num1,den1);step(y1);
% Part 2subplot(4,2,2);num2 = [0 2 0];den2 = [1 8 15];y2 = tf(num2,den2);step(y2);
% Part 3subplot(4,2,3);num3 = poly([-2 -5 -5]);den3 = poly([-1 2 -2]);y3 = tf(2*num3,den3);
step(y3);
% Part 4subplot(4,2,4);num4 = [1 1 1];den4 = poly([0 -1 -1]);y4 = tf(2*num,den4);step(y4);
% Part 5subplot(4,2,5);s = tf('s');num5 = [3 9 12];den51 = [1 2];
den52 = [1 5 11];den5 = conv(den51,den52);y5 = (3*(s^2) + 9*s + 12)/((s+2)*(s^2 + 5*s + 11));step(y5);
% Part 6subplot(4,2,6);s = tf('s');y6 = exp(-s)/(s^2);
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
2/14
step(y6);
% Part 7subplot(4,2,7);num7 = [];den7 = [0 -2 16];y7 = zpk(num7,den7,5);
step(y7);
% Part 8subplot(4,2,8);num8 = [0];den8 = [-5-2j -5+2j -3];y8 = zpk(num8,den8,6);step(y8);
Figure Orders
PART - 1 PART 2
PART 3 PART 4
PART 5 PART 6
PART 7 PART 8
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
3/14
EXERCISE 3:clc; clear all;close all
num = {[1 6] ; 1};den = {[1 4 4] ; [1 0 0]};y = tf(num,den);step(y);
EXERCISE 4:
clc; clear all;close all
num = {[0 6],[1 3] ; [1 0],[0 1]};den = {[1 5],[1 5] ; [1 5],[1 5]};y = tf(num,den);step(y);
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
4/14
EXERCISE 5:
clc;clear all;close all
% Part 1num1 = [1 5 6];den1 = [1 9 12];y1 = tf(num1,den1);subplot(4,2,1);pzmap(y1);
% Part 2num2 = [0 2 0];den2 = [1 8 15];y2 = tf(num2,den2);subplot(4,2,2);
pzmap(y2);
% Part 3num3 = poly([-2 -5 -5]);den3 = poly([-1 2 -2]);y3 = tf(2*num3,den3);subplot(4,2,3);pzmap(y3);
% Part 4num4 = [1 1 1];den4 = poly([0 -1 -1]);y4 = tf(2*num4,den4);
subplot(4,2,4);pzmap(y4);
% Part 5s = tf('s');num5 = [3 9 12];den51 = [1 2];den52 = [1 5 11];den5 = conv(den51,den52);y5 = (3*(s^2) + 9*s + 12)/((s+2)*(s^2 + 5*s + 11));subplot(4,2,5);pzmap(y5);
% Part 6s = tf('s');y6 = exp(-s)/(s^2);subplot(4,2,6);pzmap(y6);
% Part 7num7 = [];
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
5/14
den7 = [0 -2 16];y7 = zpk(num7,den7,5);subplot(4,2,7);pzmap(y7);
% Part 8j = sqrt(-1);
num8 = [0];den8 = [-5-2j -5+2j -3];y8 = zpk(num8,den8,6);subplot(4,2,8);pzmap(y8);
Figure Orders
PART - 1 PART 2
PART 3 PART 4
PART5 PART
6
PART 7 PART 8
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
6/14
EXERCISE 6:
clc;clear all;close all
% Part 1(original)num1 = [1 5 6];
den1 = [1 9 12];y1 = tf(num1,den1);subplot(2,2,1);pzmap(y1);
% Part 4(original)num4 = [1 1 1];den4 = poly([0 -1 -1]);y4 = tf(2*num4,den4);subplot(2,2,2);pzmap(y4);
% Part 1(roots method)num11 = roots(num1);den11 = roots(den1);y11 = zpk(num11,den11,1);subplot(2,2,3);pzmap(y11);
% Part 4(roots method)num44 = roots(num4);den44 = roots(den4);y44 = zpk(num44,den44,2);subplot(2,2,4);pzmap(y44);
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
7/14
EXERCISE 7:
clc;clear all;close all
% Part 3(original)num3 = poly([-2 -5 -5]);den3 = poly([-1 2 -2]);y3 = tf(2*num3,den3);subplot(2,2,1);pzmap(y3);
% Part 8(original)j = sqrt(-1);num8 = [0];den8 = [-5-2j -5+2j -3];y8 = zpk(num8,den8,6);subplot(2,2,2);pzmap(y8);
% Part 3(tf2zp method)[z p k]= tf2zp(num3,den3);y33 = zpk(z,p,k);subplot(2,2,3);pzmap(y33);
% Part 8(tf2zp method)[z1 p1 k1]= tf2zp(poly(num8),poly(den8));y88 = zpk(z1,p1,k1);subplot(2,2,4);pzmap(y88);
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
8/14
EXERCISE 8:
clc; clear all; close all;
% Part a
num1 = [0 3 -1];den1 = [1 -3 2];[r1,p1,k1] = residue(num1,den1);
() = 5 2
% Part bnum2 = [3 3 -1];den2 = [1 -3 2];[r2,p2,k2] = residue(num2,den2);
() = 17 5 3
% Part cnum3 = [7 2 3 -1];den3 = [0 1 -3 2];[r3,p3,k3] = residue(num3,den3);
() = 69 11 7 2 3
% Part dnum4 = [0 2 3 -1];
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
9/14
den4 = [1 -5 8 -4];[r4,p4,k4] = residue(num4,den4);
() = 2 13 4
% Part enum5 = [0 2 3 -1];den5 = [1 -3 4 -2];[r5,p5,k5] = residue(num5,den5);
() = (1 3.5)(+) (1 3.5)() 4
% Part fnum6 = [0 0 1];den6 = [1 0 4];[r6,p6,k6] = residue(num6,den6);
() = 0.25 0.25
% Part gnum7 = [0 0 2 0 -1];den7 = [1 0 2 0 1];[r7,p7,k7] = residue(num7,den7);
() = 0.25 0.75 0.25 0.75
EXERCISE 9:
There are no 'k-termsof an equation if denominator has higher degree than
numerator.Else number of 'k-terms is equal to(degree of Num. - degree of Den. + 1)
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
10/14
EXERCISE 11:
clc; clear all; close all;
s = tf('s');
% Part aY1 = (1/s);subplot(5,2,1);impulse(y1);
% Part bY2 = (1/(s-5));subplot(5,2,2);impulse(y2);
% Part cY3 = (1/(s-20));subplot(5,2,3);impulse(y3);
% Part dY4 = (1/(s+5));subplot(5,2,4);impulse(y4);
% Part eY5 = (1/(s+20));subplot(5,2,5);impulse(y5);
% Part fY6 = (1/(s^2 + 25));subplot(5,2,6);impulse(y6);
% Part gY7 = (1/(s^2 + 400));subplot(5,2,7);impulse(y7);
% Part hY8 = (1/(s^2 + 10*s + 50));subplot(5,2,8);
impulse(y8);
% Part iY9 = (1/(s^2 - 10*s + 50));subplot(5,2,9);impulse(y9);
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
11/14
PART A PART B
PART C PART D
PART E PART F
PART G PART H
PART - I
EXERCISE 12:
clc; clear all; close all;
s = tf('s');
y1 = (1/s);y2 = (1/(s-5));y3 = (1/(s-20));y4 = (1/(s+5));y5 = (1/(s+20));y6 = (1/(s^2 + 25));y7 = (1/(s^2 + 400));y8 = (1/(s^2 + 10*s + 50));y9 = (1/(s^2 - 10*s + 50));
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
12/14
hold on;pzmap(y1);pzmap(y2);pzmap(y3);pzmap(y4);pzmap(y5);
pzmap(y6);pzmap(y7);pzmap(y8);pzmap(y9);
EXERCISE 13:
clc; clear all; close all;
s = tf('s');
y = ((5*s^2 - 2*s + 23)/(s^2 + 6*s + 5));subplot(2,1,1);impulse(y);subplot(2,1,2);step(y);
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
13/14
Explanation:
Yes the shapes of the natural responses are indeed determined by the location
of poles and zeros and the response of the system changes abruptly at location
of poles and zeros it either becomes zero or it becomes unbounded.
EXERCISE 14:
numT = [0 1 2];denT = [1 1 0];sysT = tf(numT,denT);t=0:0.01:5;u=[zeros(1,200) 10*ones(1,10) zeros(1,100) -10*ones(1,10) zeros(1,181)];y = lsim(sysT,u,t);subplot(2,1,1);plot(t,u);subplot(2,1,2);plot(t,y);
Explanation:
This code firstly creates a transfer function using numT and denT (numerator and denominator coefficients), then
time period is defined, and then input signal u is definedas a sort of small square pulses of magnitude 10 and -
10 at two different points.
Next, the obtained system sysT is live simulated using the lsim command with input signals t and u and then
both the result and input signal u are plotted against t.
-
7/25/2019 LAB1 Wednesday(2pm) Azaan Azeem
14/14
This code helps us to determine the live simulation results shown by a system when simulated under controlled
input signals.
The following plots are obtained of input signal u and results y against time, respectively;