function kanon_kugle
theta = 40;
x0 = 0;
u0 = 50*cosd(theta);
y0 = 0;
v0 = 50*sind(theta);
SB = [x0,u0,y0,v0];
t0 = 0; tf = 30;
tspan = (t0:0.08:tf);
options = odeset("Events", @events);
[~, state_values] = ode45(@bane, tspan, SB, options);
x = state_values(:,1);
y = state_values(:,3);
axis([0 500 0 300])
hold on
n=1;
while n < 1000
plot(x(n),y(n),"b.",'MarkerSize',30)
xlabel("x forskydning (m)"), ylabel("y forskydning (m)")
title("Scorched Earth")
pause(0.0001)
n = n + 1;
clf
xlim([0,500])
ylim([0,500])
hold on
end
function sdot = bane(~,s)
g = 9.8;
sdot = [s(2); 0; s(4); -g];
end
function [check, isterminal, direction] = events(~,s)
direction = [];
isterminal = 1;
check = double( s(3) <= 0 );
end
end