ambrosini.us

Historical teaching note · 2006-04 · restored from archived Blogger HTML

Tracking a projectile - a simple initial value problem

Ever wondered what happened when you shot your shotgun straight up in the air when you were a kid. Well according to this simulation, in 3.5 seconds, the shot would be at its highest point about 145 meters. Then it takes about 7.5 seconds for it to come back to earth. Matlab code: clear; a = 0; % start time in seconds (usually zero) b = 15; % end time in seconds alpha = 300; % initial speed in m/s (i.e. coming out of the gun or whatever, pointing up) m = .11; % mass of the object in kg N = 1500; h = (b - a)/N; t = a; w = alpha; height = 0; g = 9.8; kbym = .002/m; for i = 1:N height = height + h * w; w = w + h * (- g - kbym * w * abs(w) + h * kbym * g * abs(w) + h*kbym*kbym *w*w*w); % here's the function of interest... matlab is annoying t = a + i * h; output(i,1) = i; output(i,2) = t; output(i,3) = w; output(i,4) = height; end output And a pretty picture: