%Solution of 2d linear dynamics with exponential boost

clear all

global omega


N=2;

omega=1;

%x=randn(2,10);
x=[0;1];
t=0;

%v=vel2d(x,t);

A=[0,1;-omega^2,0];

x0=x(:,1);

dt=1;

xt(:,1)=x0;

EA=expm(A*dt);

Nt=100;
t(1)=0;

for it=2:Nt

     t(it)=(it-1)*dt;
     xt(:,it)=EA*xt(:,it-1);

end

figure(56)
plot(t,xt(1,:),'r',t,xt(2,:),'b','Linewidth',2)
xlabel('$t$','Fontsize',18,'Interpreter','Latex')
ylabel('$x, ~\dot x$','Fontsize',18,'Interpreter','Latex')
grid on
set(gca,'Fontsize',24)
drawnow
%pause
figure(58)
plot(xt(1,:),xt(2,:),'.r','Linewidth',2,'Markersize',14)
xlabel('$x$','Fontsize',18,'Interpreter','Latex')
ylabel('$\dot x$','Fontsize',18,'Interpreter','Latex')
grid on
set(gca,'Fontsize',24)
drawnow
axis('equal')
%pause



