% BASEBALL.M % % % clear % % Input physical variable, work variables and initial conditions. % c_D = 0.4; rho = 0.0023; g = 32.2; m = .319/g; R = .121; A = pi*(R^2); k_D = c_D*rho*A/(2*m); k_L = R*rho*A/(2*m); T_f = 0.6; tspan = 0:T_f/100:T_f; omega = [0 0 0]; u0 = [0 125 0 0 4 5]; % % Now let's integrate the system over the time inverval [0,Tf] % using the Runge-Kutta routine ode45.m. % options = odeset('RelTol',1e-4,'AbsTol',1e-4); [T,Uapp] = ode45('baseball_eval',tspan,u0,options,k_D,k_L,g,omega); % % Finally, we'll plot the solution. Remember that Uapp has % the following components: % % Uapp = [x v_x y v_y z v_z] % x = Uapp(:,1); v_x = Uapp(:,2); y = Uapp(:,3); v_y = Uapp(:,4); z = Uapp(:,5); v_z = Uapp(:,6); figure(1) plot(x(1:86),z(1:86)) axis([0 60 0 7]) xlabel('x-axis') ylabel('z-axis') % % End of program %