figure('Position',[500 500 700 350])
%% first solution
gl = 1.5; vel = 4;
res = @(z) residual(z,gl,vel);
z = fzero(res,pi/4);

opts=odeset('events',@endevent,'RelTol',1e-9,'AbsTol',1e-11);
y0=[0; vel*cos(z); 0; vel*sin(z)];
[~,~,te,~]=ode45(@shoot,[0 inf],y0,opts);

tf = te(end);
h = tf/1000;
[~,y]=ode45(@shoot,0:h:tf,y0,opts);

plot(y(:,1),y(:,3),'LineWidth',2); hold on;

%% second solution
gl = 1.5; vel = 4;
res = @(z) residual(z,gl,vel);
z = fzero(res,pi/2);

opts=odeset('events',@endevent,'RelTol',1e-9,'AbsTol',1e-11);
y0=[0; vel*cos(z); 0; vel*sin(z)];
[~,~,te,~]=ode45(@shoot,[0 inf],y0,opts);

tf = te(end);
h = tf/1000;
[t,y]=ode45(@shoot,0:h:tf,y0,opts);

plot(y(:,1),y(:,3),'LineWidth',2);

%% format
axis([0 1.5 0 0.6])
ax = gca;
set(ax,'TickLabelInterpreter','latex');
ax.TickLength = [0.02 0.02];
set(gca,'fontsize',20)
str='$x$';
xlabel(str,'interpreter','latex','FontSize',24);
str='$y$';
ylabel(str,'interpreter','latex','FontSize',24);

tightfig;