Question
MATLAB,
please provide code script

Objective: Create a function file that animates projectile motion defined by the following equations in a subplot. Your funct
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB code:

% Asking the user to enter the value of speed

v0 = input("Enter the value of launch speed");

% Asking the user to enter value of angle

theta = input("Enter the value of angle in degree");

% converting degree to radian

theta = theta * pi / 180;

% Defining the value of t

t = 0 : 0.01 : 10;

% getting the remaining parameter

g = 9.8;

x = v0 * cos(theta) * t;

y = v0 * sin(theta) * t + (-0.5 * g * (t .^ 2));

tmax = 2 * v0 * sin(theta) / g ;

R = v0 * cos(theta) * tmax;

Vver = v0 * sin(theta) - (g * t);

% Subplotting the figure

plt1 = subplot(2,1,1);

xlabel('x')

ylabel('y')

title('y vs x')

axis([0 R+2 0 max(y)+2])

anim1 = animatedline('Color','r');

plt2 = subplot(2,1,2);

xlabel('t')

ylabel('v')

title('Velocity vs Time')

axis([0 2*tmax 0 max(Vver)+2])

anim2 = animatedline('Color','k');

for i = 1 : length(t)

addpoints( anim1 , x(i) , y(i)) ;

addpoints( anim2 , t(i) , Vver(i)) ;

drawnow

pause(0.001);

end

1 % Asking the user to enter the value of speed vo = input(Enter the value of launch speed); 2 - 3 4 % Asking the user to eplt2 = subplot(2,1,2); xlabel(t) y label(v) title(Velocity vs Time) axis([O 2* tmax max(Vver)+2]) anim2 = animatedline(

OUTPUT: (it will be animaated when you will run)

y vs x 3. 2 у 1 0 2 4 6 8 10 Velocity vs Time > 2 0 0.5 1.5 2 1 t

Add a comment
Know the answer?
Add Answer to:
MATLAB, please provide code script Objective: Create a function file that animates projectile motion defined by...
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
  • Could somebody help me with this question for the coding on MATLAB? Thank you Projectile Motion...

    Could somebody help me with this question for the coding on MATLAB? Thank you Projectile Motion The distance a projectile travels when fired at an angle Θ is a function of time and can be divided into horizontal distance, dVotcos(O) and the vertical distance is dy Vot sin(0)-0.5gt2. Suppose a projectile is fired at an initial velocity of 100 m/s and a launch angle of /4 radians (45°). Use ezplot to graph horizontal distance on the x -axis and vertical...

  • EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal...

    EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal direction and with an initial speed of 40 m/s. (A) How do the vertical and horizontal components of the projectile's velocity vary with time? (B) How long does it remain in flight? (C) For a given launch speed, what launch angle produces the longest time of flight? CONCEPTUALIZE Consider the projectile to be a point mass that starts with an initial velocity, upward and...

  • MATLAB Write a user defined function for a projectile motion. If a ball is launched from...

    MATLAB Write a user defined function for a projectile motion. If a ball is launched from initial position(0,0) with a velocity v0 at angle θ, determine your horizontal and vertical position. Please plot x vs. t, y vs. t and y vs. x.

  • EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal...

    EXPLORE A projectile is launched with a launch angle of 30° with respect to the horizontal direction and with an initial speed of 10 m/s. s0 (A) How do the vertical and horizontal components of the projectile's velocity vary with time? 40 35 (B) How long does it remain in flight? 25 (C) For a given launch speed, what launch angle produces the longest time of flight? 15 10 toy CONCEPTUALIZE Consider the projectile to be a point mass that...

  • PROJECTILE MOTION OBJECTIVE: The purpose of this lab is to study the properties of projectile motion....

    PROJECTILE MOTION OBJECTIVE: The purpose of this lab is to study the properties of projectile motion. From the motion of a steel ball projected horizontally, the initial velocity of the ball ean be determined from the measured range. For a given initial velocity, the projectile range will be measured for various initial angles, and calculated by applying the theory for motion with constant acceleration BASIC PRINCIPLES: Projectile motion occurs when an object in a two-dimensional plane experiences motion only due...

  • I want the math lab code for theses problems in a unique way

    I want the math lab code for theses problems in a unique way Theory A projectile is launched from point A up an incline plane that makes an angle of 10 with the horizontal. The mountain is 6,000 m high. Vo 10° Figure 1: Flightpath of a projectile. If we neglect the air resistance, the flight path of a projectile launched at an initial speed vo and an angle θ of departure relative to the horizontal is a parabola (see...

  • Q2. A) Projectile motion (General launch angle): Select any one of the options as answer A...

    Q2. A) Projectile motion (General launch angle): Select any one of the options as answer A football kicker is attempting a field goal from 44 m out. The ball is kicked and just clears the lower bar with a time of flight of 2.9 s. If the angle of the kick was 45°, what was the initial speed(Vo) of the ball, assuming no air resistance? a) 21.5 m/s b) 19.7 m/s c) 2.2 m/s d) 39 m/s (Hint: x-Xo =...

  • I have no idea what to do. Can you please include the code with it? Thanks!...

    I have no idea what to do. Can you please include the code with it? Thanks! 2. The trajectory motion of a projectile is given as a function of time. x(t) = (V, cost 1 y(t) = (v, sin(O)t - 5 gta where x is the horizontal distance or down range of the projectile in feet y is the vertical motion or height of the projectile in feet ve is the initial velocity = 200 ft/s O is the angle...

  • Simulation: Projectile motion, with and without air drag, plotted, Question 2 Note: use principles of physics...

    Simulation: Projectile motion, with and without air drag, plotted, Question 2 Note: use principles of physics to solve the problem and then verify your answer using the simulation. Assume that the acceleration due to gravity has a magnitude of g 9.30 m/s2. If the range of the projectile is 6.76 m, the time-of-flight is T-1.28 s, and air resistance is turned off, determine the following (a) What is the launch angle of the projectile? Number Units the absolute tolerance is...

  • Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial...

    Please help me correct my MATLAB script code for this problem, thank you!! A projectile PA is launched from point A towards the east with an initial launch velocity voa and an initial lauw angle of 0x. The impact point of the projectile Pa is a point B in a valley with an ordinate, yon, located below the clevation of point A. The launch from point A is instantaneously detected at point B, and a counter projectile P launched simultaneously...

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