Mat Lab Assignment Cum Test

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

s = tf('s');

M=0.5;
m=0.23;
a=1/(M+m);
g=9.8;
l=0.321;
x = 3*a/(3*m*l*a - 4*l)
y = 4*a/(4-3*m*a)
xx = (3*g)/(4*l - 3*m*l*a)
yy = (-3*m*a*g)/(4-3*m*a)
a=[0 1 0 0 ;xx 0 0 0; 0 0 0 1;yy 0 0 0];
b = [0; x; 0; y]
c = [1 0 0 0];
% w is (sI-A)^-1
w = inv(s*eye(4) - a);
func = c*w*b

%hence we have got our open loop transfer function


%we need to find our a compensator
k = -((34.65*(s+5))/(s+12.43));
func1 = k*func ;
poles = pole(func1);
zeroes = zero(func1) ;
m = length(poles);
n = length(zeroes);
centroid = (sum(poles) - sum(zeroes))/(m-n) ;
for i=1:m-n
angle(i)=(2*(i-1)+1)*180/(m-n) ;
end
x = centroid:80;
y = -25:25
m1 = tand(angle(1));
m2 = tand(angle(2));
y1 = m1*(x-centroid);
y2 = m2*(x-centroid);
%we need to divide by 2 because the DC gain was comming 2
check = 1/2*feedback(func1,1);
stepinfo(check)
figure(1)
step(check)
grid on;
figure(2)
rlocus(func1)
hold on;
plot(centroid,0,'x');
hold on;
plot(x,y1,'k-')
hold on;
plot(x,y2,'k-')
hold on;
plot(y,centroid,'k-')

1
hold on;
grid on;

x =

-4.1909

y =

1.7937

xx =

29.9820

yy =

-3.0323

b =

0
-4.1909
0
1.7937

func =

-4.191
------------------------
s^2 - 1.51e-14 s - 29.98

Continuous-time transfer function.

y =

Columns 1 through 13

-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15
-14 -13

Columns 14 through 26

-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2


-1 0

Columns 27 through 39

2
1 2 3 4 5 6 7 8 9 10 11
12 13

Columns 40 through 51

14 15 16 17 18 19 20 21 22 23 24
25

ans =

struct with fields:

RiseTime: 0.1886
SettlingTime: 0.9406
SettlingMin: 0.9486
SettlingMax: 1.1860
Overshoot: 15.4565
Undershoot: 0
Peak: 1.1860
PeakTime: 0.4144

3
Published with MATLAB® R2020a

You might also like