end
num=40.6 ;
den=[1 10 27 22.06] ;
[A,B,C,D]=tf2ss(num,den) ;
r=1 ;
h=0.1 ;
T=10 ;
t=0.1 :h :10 ;
y4= f22(A,B,C,D,r,T,h);
plot(t,y4,'b');
hold on
to=0 ;
xo=[0 ;0 ;0];
yo=0 ;
R=r;
for i=1 :T/h
k1=A*xo+B*R;
xo= xo+h*k1 ;
yo=[yo,C*xo+D];
to=[to,to(i)+h];
end
plot(to,yo,'r');
hold on
yt=1.84-4.95*t.*exp(-1.88*t)-1.5*exp(-1.88*t)-0.34*exp(-6.24*t); plot(t,yt,'k') ;
legend('y4','yo','yt')
2.3
f23.m
b=b/a(1);a=a/a(1);A=a(2:n+1);
A=[rot90(rot90(eye(n-1,n)));-fliplr(A)];
B=[zeros(1,n-1),1]';
m1=length(b);
C=[fliplr(b),zeros(1,n-m1)];
Ab=A-B*C*V;
X=X0';
y=0;t=T0;
N=round((Tf-T0)/h);
for i=1:N
K1=Ab*X+B*R;
K2=Ab*(X+h*K1/2)+B*R;
K3=Ab*(X+h*K2/2)+B*R;
K4=Ab*(X+h*K3)+B*R;