EXP-2
Exp -5
clc
close all
clear all
a=[0 1 0 0;0 -1.818 2.6727 0;0 0 0 1;0 -0.4545 31.1818 0];
b=[0;1.8182;0;4.545];
c=[1 0 0 0;0 0 1 0];
d=[0;0];
sys=ss(a,b,c,d);
if(rank(ctrb(sys))==length(a))
disp('controllable')
else
disp('uncontrollable')
end
if((rank(obsv(sys)))==length(a))
disp('observable')
else
disp('unobservable')
end
e=eig(a)
if(e<0)
disp('stable')
else
disp('unstable')
end
Exp -5
clc
close all
clear all
a=[0 1 0 0;4.4537 0 0 0;0 0 0 1;-0.5809 0 0 0];
b=[0 ;-0.3947; 0; 0.9211];
c=[0 0 1 0];
d=[0];
s=tf('s');
x0=[1;1;1;1];
sys=ss(a,b,c,d);
if(eig(a)<0)
disp('stable')
else
disp('unstable')
end
eigen=eig(a)
if(rank(ctrb(sys))==length(a))
disp('controllable')
else
disp('uncontrollable')
end
if((rank(obsv(sys)))==length(a))
disp('observable')
else
disp('unobservable')
end
g=tf(sys)
step(sys)
figure
impulse(sys)
figure
step(sys/s)
figure
initial(sys,x0)
figure
[num,den]=ss2tf(a,b,c,d);
ce=den
r=roots(den)
f=feedback(g,1)
step(f)
if(eig(f)<0)
disp('stable')
else
disp('unstable')
end
p=[-2+i*5 -2-i*5 -3 -10];
k=acker(a,b,p)
sys2=canon(sys,'companion')
sys3=canon(sys,'modal')
J=jordan(a)
EXP-6
EXP-6
clc
clear all
close all
syms s
s=tf('s');
g=[1/(s+1) 0 (s+1)/((s+1)*(s+2)) ;-1/(s-1) 1/(s+2) 1/(s+2)]
sys=ss(g);
[A,B,C,D]=ssdata(sys)
step(g)
figure
step(g/s)
co=ctrb(A,B);
if(rank(co)==length(A))
disp('controllable')
else
disp('uncontrollable')
end
ob=obsv(A,C);
if(rank(ob)==length(A))
disp('observable')
else
disp('unobservable')
end
if(eig(g)<0)
EXP-7
clc
clear all
close all
A=[0 1 0 0;4.4537 0 0 0;0 0 0 1;-0.5805 0 0 0];
B=[0;-0.3947;0;0.5211];
C=[0 0 1 0];
D=[0];
p1=[-2 -1 -3+i*4 -3-i*4];
p2=[-3+i*3 ;-3-i*3; -10; -10];
sys=ss(A,B,C,D);
if(rank(ctrb(sys))==length(A))
k=acker(A,B,p1)
A1=A-B*k;
sys1=ss(A1,B,C,D)
else
disp('since system is uncontrollable state feedback cant be formed')
end
if(rank(obsv(sys))==length(A))
k1=acker(A',C',p2)
A2=A'-k1*C';
sys2=ss(A2,B,C,D)
else
disp('since system is unobservable state feedback cant be formed')
end
EXP-8
EXP-9EXP-8
clc
clear all
close all
A=[0 1 0 0 0 0 ;-4.7059 -0.0887 0 0 1.3588 0;0 0 0 1 0 0;0 0 0 -5 1.617 4.5;0 0 0 0 -0.9091 0;0 0 0 0 0 1];
B=[0 0;0 0;0 0;0 0;1 0;0 0.8];
C=[1 0 0 0 0 0;0 0 1 0 0 0];
D=[0 0; 0 0];
sys=ss(A,B,C,D);
syms s S
s=tf('s');
if(rank(ctrb(sys))==length(A))
disp('controllable')
else
disp('uncontrollable')
end
if(rank(obsv(sys))==length(A))
disp('observable')
else
disp('unobservable')
end
step(sys)
figure
impulse(sys)
figure
clc
clear all
close all
z=tf('z');
num=[0.3679 0.2642];
den=[1 -1.3679 0.3679];
sys=filt(num,den,0.1)
step(sys)
figure
impulse(sys)
figure
step(sys/z)
if(eig(sys)<1)
disp('stable')
else
disp('unstable')
end
EXP-10
EXP-10
clc
clear all
close all
Kp1=5;Kp2=5;
Ki1=0;
Ki2=10;
t1=1;
t2=5;
s=tf('s');
G=1/s*(s+1);
z1=c2d(G,1);
d1z=5;
num1=d1z*z1;
sys1=feedback(num1,1)
subplot(2,2,1);
step(sys1)
z2=c2d(G,5);
num2=d1z*z2;
sys2=feedback(num2,1);
subplot(2,2,2);
step(sys2)
d2z=Kp2*Ki2/s;
num3=[5,10];
den3=[1,10];
[d2z1,d2z2]=bilinear(num3,den3,1);
sys3=tf(d2z1,d2z2,1);
z3=c2d(G,1);
num4=sys3*z3;
sys4=feedback(num4,1);
subplot(2,2,3);
step(sys4)
[d3z1,d3z2]=bilinear(num3,den3,02);
sys5=tf(d3z1,d3z2,5);
z4=c2d(G,5);
num5=sys5*z4;
EXP-11
EXP-12
EXP-11
clc
clear all
close all
s=tf('s');
Kp=1.65*10^6;
Kg=3.71*10^5;
Jv=41822;
t1=0.2;
t2=0.5;
t3=0.8;
G=Kp/(s*(Kg+(Jv*s)))
tf1=c2d(G,t1);
tf2=c2d(G,t2);
tf3=c2d(G,t3);
rlocus(tf1)
figure
rlocus(tf2)
figure
rlocus(tf3)
EXP-12
clc
clear all
close all
s=tf('s');
Kp=1.65*10^6;
Kg=3.71*10^5;
Jv=41822;
t1=0.2;
t2=0.5;
t3=0.8;
G=Kp/(s*(Kg+(Jv*s)))
tf1=c2d(G*0.048,t1);
tf2=c2d(G*0.03,t1);
tf3=c2d(G*3.2,t1);
tf4=c2d(G*0.269,t2);
tf5=c2d(G*0.2,t2);
tf6=c2d(G*2,t2);
tf7=c2d(G*0.269,t3);
tf8=c2d(G*0.2,t3);
tf9=c2d(G*1,t3);
bode(tf1)
figure
nyquist(tf1)
figure
EXP-13
EXP-14
EXP-13
clc
clear all
close all
A=[0 1 0 0 0 0;-4.7059 -0.0852 0 0 1.3585 0;0 0 0 1 0 0;0 0 0 -5 1.617 4.5;0 0 0 0 -0.9091 0;0 0 0 0 0 -1];
B=[0 0;0 0;0 0;0 0;1 0;0 0.8];
C=[1 0 0 0 0 0;0 0 1 0 0 0];
D=[0 0;0 0];
t=0.5;
sys=ss(A,B,C,D);
g=tf(sys);
z=tf('z');
sysd=c2d(g,t)
[f,g,c,d]=ssdata(sysd)
p=[-0.5+i*0.25 -0.5-i*0.25 0.5+i*0.25 0.5-i*0.25 0.5 -0.5];
k=place(A,B,p)
m=A-B*k
e=eig(A)
EXP-14
clc
close all
clear all
m=0.1;
M=1;
k=0.091;
b=0.0036;
A=[0 1 0 0;-k/m -b/m k/m b/m;0 0 0 1;k/M b/M k/M b/M];
B=[0;0;0;1/M];
C=[1 0 0 0;0 0 1 0];
%X=[d;d';x;x'];
D=[0];
sys=ss(A,B,C,D);
z=tf('z')
tfd=c2d(sys,0.5);
[f,g,c,d]=ssdata(tfd)
p=[-0.00001 -0.05 -0.04 -0.03];
k=place(f,g,p)
Ad=f-g*k
Bd=zeros(4,1);
dbc=ss(Ad,Bd,C,D,0.5)
step(dbc)
No comments:
Post a Comment