Final Answer:
The code in matlab
The distance a projectile travels when fired at an angle θ is a function of time and can be divided into horizontal and vertical distances
```matlab
% Part a
t = 0:0.1:20;
Vo = 100;
theta = pi/4;
g = 9.8;
Ht = t .* Vo .* cos(theta);
Vt = t .* Vo .* sin(theta) - 0.5 * g * t.^2;
figure;
subplot(2,1,1);
plot(t, Ht);
title('Horizontal Distance vs Time');
xlabel('Time (s)');
ylabel('Horizontal Distance (m)');
subplot(2,1,2);
plot(t, Vt);
title('Vertical Distance vs Time');
xlabel('Time (s)');
ylabel('Vertical Distance (m)');
% Part b
figure;
plot(Ht, Vt);
title('Horizontal Distance vs Vertical Distance');
xlabel('Horizontal Distance (m)');
ylabel('Vertical Distance (m)');
% Part c
launch_angles = [pi/3, pi/5, pi/7];
figure;
for i = 1:length(launch_angles)
theta_i = launch_angles(i);
Ht_i = t .* Vo .* cos(theta_i);
Vt_i = t .* Vo .* sin(theta_i) - 0.5 * g * t.^2;
plot(Ht_i, Vt_i, '--');
hold on;
end
legend('\theta = \pi/3', '\theta = \pi/5', '\theta = \pi/7');
title('Projectile Motion for Different Launch Angles');
% Part d
figure;
subplot(2,2,1);
plot(t, Ht);
title('Horizontal Distance vs Time');
xlabel('Time (s)');
ylabel('Horizontal Distance (m)');
subplot(2,2,2);
plot(t, Vt);
title('Vertical Distance vs Time');
xlabel('Time (s)');
ylabel('Vertical Distance (m)');
subplot(2,2,3);
plot(Ht, Vt);
title('Horizontal Distance vs Vertical Distance');
xlabel('Horizontal Distance (m)');
ylabel('Vertical Distance (m)');
subplot(2,2,4);
for i = 1:length(launch_angles)
theta_i = launch_angles(i);
Ht_i = t .* Vo .* cos(theta_i);
Vt_i = t .* Vo .* sin(theta_i) - 0.5 * g * t.^2;
plot(Ht_i, Vt_i, '--');
hold on;
end
legend('\theta = \pi/3', '\theta = \pi/5', '\theta = \pi/7');
title('Projectile Motion for Different Launch Angles');
```
Explanation:
In part a, MATLAB code is provided to calculate and plot the horizontal and vertical distances traveled by a projectile over time. The horizontal distance (`Ht`) and vertical distance (`Vt`) are computed using the given equations for a launch angle of π/4 (45 degrees) and an initial velocity of 100 m/s. The resulting plots show the projectile's motion over the specified time range.
In part b, a new figure window is created to display the horizontal distance on the x-axis and vertical distance on the y-axis in a single plot.
Part c involves calculating and plotting horizontal and vertical distances for launch angles of π/3, π/5, and π/7. Each trajectory is represented by a different line style (solid, dashed, and dotted), and a legend is added for clarity.
Finally, in part d, all four plots from parts a to c are combined into a single figure using the `subplot` function. This allows for a comprehensive view of the projectile's motion under different conditions within a single figure window.