Question

Using MATLAB to plot the trajectory of a projectile: Consider a cannon launching a cannonball at...

Using MATLAB to plot the trajectory of a projectile:

Consider a cannon launching a cannonball at initial velocity, v, towards a wall. With an elevation of launch angle, θ, distance to wall, D, and wall height, h.

Write a MATLAB function to plot the trajectory of the cannonball and return information in the following form:
>> [outcome, impact] = Q3 STNO(v,theta,D,h)

where v, theta, D and h are the launch velocity (m/s), launch angle (radians), distance to wall (m) and height of wall (m) as stated above. For the case where the ball lands before reaching the wall, outcome should be set to 0 (zero) and impact to NaN. If the ball strikes the wall, then outcome should be 1 (one) and impact should be the height above the ground where the ball hits the wall. Finally, for the case where the ball overshoots the wall, outcome should be set to 2 and impact to NaN.  Keep all inputs positive and θ < π/2.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB function

function [outcome, impact] = Q3STNO(v,theta,D,h)
g=9.81;
D=linspace(0,D,100);
vertical_distance=tand(theta)*D-(g*D.^2/(2*v^2*cosd(theta)^2));
if vertical_distance(end)<=0
outcome=0;
impact=NaN;
disp('No impact')
elseif vertical_distance(end)>0 && vertical_distance(end)<=h
outcome=1;
impact=vertical_distance(end);
disp('Impact happened')
else
outcome=2;
impact=NaN;
disp('Overshoot')
end
plot(D,vertical_distance)

Script to call function (Result shown for all three cases by varying angle of throw)

clc
clear
close
v=10; %initial velocity
theta=60; %Angle of throw
D=4; % Distance of wall
h=3; % height of wall
[outcome, impact] = Q3STNO(v,theta,D,h)

Add a comment
Know the answer?
Add Answer to:
Using MATLAB to plot the trajectory of a projectile: Consider a cannon launching a cannonball at...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A cannon on a cliff at a height of H = 34 meters fires a cannonball...

    A cannon on a cliff at a height of H = 34 meters fires a cannonball in the horizontal direction. The initial velocity of the cannonball is 6.9 m/s. What is the horizontal distance D which the cannonball travels before it hits the ground below? What will the speed of the ball be just before it hits the ground? What direction will the cannonball be moving just before it hits the ground? Enter the angle relative to the horizontal axis....

  • A cannon shoots a cannonball from the ground level (ignore the height of the cannon) towards a cliff of height h = 170 m

    A cannon shoots a cannonball from the ground level (ignore the height of the cannon) towards a cliff of height h = 170 m. The cannonball is launched with an initial velocity of 110 m/s at an angle of 64° above the horizontal. Neglect air resistance. Assume the cannonball hits the cliff as it descends (on its way down) exactly at the edge, as shown. a. Determine the maximum height above the ground reached by the cannonball.b. What speed will the...

  • 1. Solve the following problem on a clean sheet of paper. A cannon shoots a cannonball...

    1. Solve the following problem on a clean sheet of paper. A cannon shoots a cannonball from the ground level (ignore the height of the cannon) towards a cliff of height h 170 m. The cannonball is launched with an initial velocity of 110 m/s at an angle of 64° above the horizontal. Neglect air resistance. Assume the cannonball hits the cliff as it descends (on its way down) exactly at the edge, as shown. Landing point a. Deternine the...

  • 1. A cannon fires a cannonball at an angle of 30° above horizontal. The initial velocity...

    1. A cannon fires a cannonball at an angle of 30° above horizontal. The initial velocity of the cannonball is 40 m/s. Assume the coordinate system in which x is horizontal and y is vertical. (a) What is the x-component of the initial velocity? '40 % cos ao (b) What is the y-component of the initial velocity? (c) Gravity causes a constant acceleration of 9.81 m/s. In what direction is this acceleration? (d) What affect will this acceleration have on...

  • Plot the Trajectory of a Projectile (by hand) from launch to maximum height • Launch angle...

    Plot the Trajectory of a Projectile (by hand) from launch to maximum height • Launch angle is 35 degrees • Launch height (y0) = 3 m • Initial velocity (V0) = 25 m/s • Acceleration ... ax = 0 , ay = -9.8 m/s2 Part 2 • Make a data table for x(t) and y(t) and plot the trajectory of the projectile (y vs. x) on graph paper • stop the plot when the maximum height is achieved • use...

  • A cannon-ball is fired horizontally with a speed vo = 60.0 m/s above the edge of...

    A cannon-ball is fired horizontally with a speed vo = 60.0 m/s above the edge of a cliff at point O a height h = 200 m directly above point B on the valley floor. Calculate the following: a. (4) The time t it takes the cannon ball to hit the valley floor at point C. b. (4) The horizontal range R . c. (6) The x- and y-components x v and y v , respectively, of the cannonball velocity...

  • A cannonball is fired horizontally from the top of a cit. The cannon is at height...

    A cannonball is fired horizontally from the top of a cit. The cannon is at height = 600 m above ground level and the ball is fired with initial horizontal speed to. Assume acceleration due to gravity to be 9 9.80 m/s - Part A . What is the position of the Assume that the cannon is fired at time t = 0 and that the cannonball hits the ground at time cannonball the time 27 Answer numerically in units...

  • A cannonball is fired horizontally from the top of a cliff. The cannon is at height H = 70.0m above ground level, and t...

    A cannonball is fired horizontally from the top of a cliff. The cannon is at height H = 70.0m above ground level, and the ball is fired with initial horizontal speed v0. Assume acceleration due to gravity to be g = 9.80m/s2 . Part A Assume that the cannon is fired at time t=0 and that the cannonball hits the ground at time tg. What is the y position of the cannonball at the time tg/2? Answer is 52.5 Part...

  • A circus act consists of a performer (a "human cannonball") being launched from a cannon into...

    A circus act consists of a performer (a "human cannonball") being launched from a cannon into a net at the other end of the stage. The performer (mass 60 kg) leaves the cannon at a speed of 25 m/s at an angle of 30o above horizontal. She comes out of the cannon at a height of 2 meters above the ground and lands in the net at a horizontal distance of 45 meters away from the launch point. 1. How...

  • 2. A baseball thrown from the outfield, a golf ball, or a thrown football, all will follow a trajectory (path) that has horizontal as well as vertical displacement components. If we neglect the a...

    2. A baseball thrown from the outfield, a golf ball, or a thrown football, all will follow a trajectory (path) that has horizontal as well as vertical displacement components. If we neglect the air friction on the ball, the path will be a perfect parabolic trajectory. The equations for the displacement of the ball are: Take gravity g as 9.81 meters per second, and the initial velocity, Vo, equal to 35 meters/second. Use Excel to show the ball trajectory for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT