You are on page 1of 1

Program

a=1;
b=2;
q=1;
r=2;
k=0.5;
M=[a,-b^2/r;-q,-a];
dt=0.01; x=1; t=0;
while (t<=1);
Z=exp(M.*(t-1))*[1;k]; p=Z(2)/Z(1);
u=-b*p*x/r;
x=x+dt*(a*x+b*u);
t=t+dt;
end;
plot(u,t)
plot(x,t)

Graph

You might also like