A projectile motion (i.e. cannon) can be modeled via the following equations: x=u cosθ t y=-0.5 g t^2+u sinθ t Where: x: Position of the cannonball after t seconds in the x-direction (meters) y: Position of the cannonball after t seconds in the y-direction (meters) u: Initial velocity of the cannonball (meters per second) g: Acceleration due to gravity (meters per second squared) t: Time (seconds) In this question, we are trying to see the effects of the angle ϴ on the trajectory of the projectile by plotting y VS x. For: g = 9.8 m/s2 u = 10 m/s t = [0:0.01:2] s a) Create a single figure of a plot with the following requirements: A ground line at y = 0 for all time, t on the same plot, plot the trajectory (y VS x) for 2 seconds for the angles ϴ = 15,30,45,60,75 Note: this means you will need to use the plot() function for each theta value. Make a legend for your plot (based on the angles used) b) You want to determine the furthest target that the cannon can hit given the previously stated parameters. At what trajectory angle should the cannon be fired at such that the cannonball reaches its maximum distance? in matlab
(a) The Matlab code to plot will be as follows:
theta = [15,30,45,60,75];
u = 10;
g = 9.81;
t = 0:0.01:2;
for i = theta
x = u*cosd(i)*t;
y = u*sind(i)*t - (0.5*g*(t.^2));
plot(x,y); xlabel("distance"); ylabel("height"); ylim([0 6]);
hold on;
end
legend("15","30","45","60","75");
hold off;
The ouput of the code will be,
(b) From the plot we can see that the 45 degree cannon ball has the highest range ie. it travels the furthest from the launch point. Hence 45 degrees is the trajectory angle the cannon should be fired so that the cannonball reaches the maximum distance.
Get Answers For Free
Most questions answered within 1 hours.