You are on page 1of 1

function xd=ord2p1z(t,x);

global kp t1 t2 t3 u ;

xd(1)=(-(t3+t2)*x(1)+kp*t1*u)/(t3*t2)+x(2);
xd(2)=(kp*u-x(1))/(t3*t2);

end

echo off
global kp t1 t2 t3 u ;
t(1)=t0;
y(1,1)=y10;
y(1,2)=y20;uc(1)=u;
tc=to;
yc=[y10,y20];
for k=2:(th-to)/q+1,
k0=h*ord2p1z(tc,yc);
k1=h*ord2p1z(tc+h,yc+k0);
yc=yc+(k0+k1)/2;
tc=tc+h;
end;
t(k)=tc;
y(k,1)=yc(1);
y(k,2)=yc(2);
uc(k)=u;
end;
cif;
figure(1);
plot(t,y(:,1),'-r',t,uc,'-q');
grid;
title('raspuns sistem de ordin doi');
figure(2)
plot(x,y(:,2),'-b');
grid;
title('derivata raspuns');

You might also like