% Example 11-1: Projectile in 3D % Initialize the variables v0 = 250; g = 9.81; theta = 65; x0 = 3000; vx = -30; % Components of initial velocity v0z = v0*sind(theta); v0y = v0*cosd(theta); % Total flight time t_tot = 2*v0z/g; % Time vector for plotting tplot = linspace(0, t_tot, 100); % Calculate x, y, and z values for each time z = v0z*tplot - 0.5*g*tplot.^2; y = v0y*tplot; x = x0 + vx*tplot; % Find x values assuming no wind x_nowind(1:length(y)) = x0; % Plot the two sets of points plot3(x, y, z, 'k-', x_nowind, y, z, 'k--') grid on axis([0 6000 0 6000 0 2500]) xlabel('x (m)'); ylabel('y (m)'); zlabel('z (m)');