Question

MATLAB model with drag force My Solutions > Background: You will be using a MATLAB model with air resistance included to predW5 - MATLAB model with drag force these updates. Details 1012 horixontal distance traveled (meters)Previous Assessment: 0 of 7 Tests Passed (0%) Submit 0% (6%) > Gravity -g is assigned to -9.8 Comfirm that g is assigned to -value 100 = 16.3797 > VelocityX - should be a vector with the size of 1x2371 double 0% (19%) Check the following values: valuvalue 1 = 0 value 2 = 0.0150 value 10 = 0.1334 value 100 = 1.2997 Total: 0% Output vertical distance travelled 200 800 1000 4CODE GIVEN

% Create a program to plot the motion of the ping pong ball with drag.

% The program will take inputs for velocity in m/s and angle of launch.

% note that with a high speed camera I estmated a launch speed for a ping

% pong ball could be 30 m/s.

vel=30; %m/s

angle=60;

% convert the degrees into radians so MATLAB likes it

angle=angle*pi/180;

% set initial values (time, distance, mass, gravity, drag)

x(1)=0; % meters

y(1)=.01; % meters

time(1)=0; % seconds

mass=.00247; %kg ping pong ball .00247 Kg

g=-9.8; % m/sec^2

c=-0.0005; % coefficient of drag with density and area in this constant

index=1; % so I can load an array for plotting

% start to increment the motion and define it component forces

velx=vel*cos(angle);

VelocityX(1)=velx;

vely=vel*sin(angle);

VelocityY(1)=vely;

% set a time step and variable for height

deltaTime=.001; % seconds

height=y(1);

while height>=0 % check that the ball has not hit ground yet

index=index+1; % setup and index

% *******************************************************

% break velocity into its components

% *******************************************************

% *******************************************************

% use an if/else statement to check to see if the ball is moving

% down (negative). If it is, then drag has an opposite sign

% as gravity in the acceleration formula. Otherwise gravity

% and drag have the same sign. Calculate the new acceleration in the y.

% *******************************************************

% *******************************************************

% Now calculate the acceleration in the x .

% *******************************************************

% *****************************************************

% calculate the new velocity at the end of the time step

% this will have X and Y components, so you need a variable

% for each. One is velFinalX and the other is velFinalY.

% *******************************************************

% ******************************************************

% Get a new velocity vector and angle given the X and Y

% The velocity is the variable "vel" and angle is "angle"

%*******************************************************

% now save my values at this time step

time(index)=time(index-1)+deltaTime;

VelocityX(index)=velFinalX;

VelocityY(index)=velFinalY;

% and distance numbers

distX=velx*deltaTime;

distY=vely*deltaTime;

% save distance values

x(index)=x(index-1)+distX;

y(index)=y(index-1)+distY;

height=y(index);

end

plot(x,y)

title('distance traveled by ping pong ball in meters')

xlabel('horixontal distance traveled (meters)')

ylabel('vertical distance traveled (meters)')

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

Solution:---

clc
clear all
close all
format long
x=0;
y=0;
t=0;
i=1;
v0=100;
th=pi/4;
cd=0.6;
g=9.81;
while(y(i)>=0)
t=t+0.001;
x(i+1)=v0*cos(th)*t-0.5*cd*t^2;
y(i+1)=v0*sin(th)*t-0.5*cd*t^2-0.5*g*t^2;
i=i+1;
end
y=y(1:end-1);
x=x(1:end-1);
plot(x,y);
xlabel('horizontal distance travelled');
ylabel('vertical distance travelled');

- 5 x Pradeep - 0 X 56 Search Documentation Tax x eulerSystem.m Xahk. mx nse_filt.m x + 1 A MATLAB R2018 HOME PLOTS APPS EDIT

Thanks.

Add a comment
Know the answer?
Add Answer to:
CODE GIVEN % Create a program to plot the motion of the ping pong ball with...
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
  • Two thin hollow plastic spheres, about the size of a ping-pong ball with masses ( 0.004...

    Two thin hollow plastic spheres, about the size of a ping-pong ball with masses ( 0.004 kg) have been rubbed with wool. Sphere 1 has a charge -4 × 10-9 C and is at location < 0.47, -0.29, 0 > m. Sphere 2 has a charge -9 × 10-9 C and is at location < -0.42, 0.43, 0> m. It will be useful to draw a diagram of the situation, including the relevant vectors. (a) What is the relative position...

  • Two thin hollow plastic spheres, about the size of a ping-pong ball with masses (m1=m2= 0.005...

    Two thin hollow plastic spheres, about the size of a ping-pong ball with masses (m1=m2= 0.005 kg) have been rubbed with wool. Sphere 1 has a charge q1= -8 × 10-9 C and is at location < 0.24, -0.2, 0 > m. Sphere 2 has a charge q2= -8 × 10-9 C and is at location < -0.36, 0.35, 0> m. It will be useful to draw a diagram of the situation, including the relevant vectors. (i) If the two...

  • Two thin hollow plastic spheres, about the size of a ping-pong ball with masses (m1=m2= 0.008...

    Two thin hollow plastic spheres, about the size of a ping-pong ball with masses (m1=m2= 0.008 kg) have been rubbed with wool. Sphere 1 has a charge q1= -9 × 10-9 C and is at location < 0.39, -0.28, 0 > m. Sphere 2 has a charge q2= -2 × 10-9 C and is at location < -0.31, 0.47, 0> m. It will be useful to draw a diagram of the situation, including the relevant vectors. a/ What is the...

  • 1) A ping pong ball is drawn at random from an urn consisting of balls numbered...

    1) A ping pong ball is drawn at random from an urn consisting of balls numbered 4 through 9. A player wins $1 if the number on the ball is odd and loses $1 if the number is even. Let x be the amount of money a player will win/lose when playing this game, where x is negative when the player loses money. (a) Construct the probability distribution table for this game. Round your answers to two decimal places. Outcome...

  • I want Matlab code related to 14.35. 14.35 A Monte Carlo analysis can be used for...

    I want Matlab code related to 14.35. 14.35 A Monte Carlo analysis can be used for optimization. For example, the trajectory of a ball can be computed with 2 |(P14.35) x+yo 2 cos20o y=(tan0o)x where y the height (m), Go = the initial angle (radians), the initial velocity (m/s), g 9.81 m/s, and yo vo = 25 m/s, and Oo = 50", determine the maximum height and the corresponding x distance (a) analytically with calcu- lus and (b) numerically with...

  • (c) The ball is at its maximum height after _____ seconds. (d) The maximum height of...

    (c) The ball is at its maximum height after _____ seconds. (d) The maximum height of the ball is ______ meters (e) The ball traveled a total horizontal distance of _______ meters. (ROUND TO TWO DECIMAL PLACES) A baseball player throws a baseball with an initial speed of 155 feet per second at an angle of 23 to the horizontal. The ball leaves his hand at a height of 6 feet. (a) Find parametric equations that describe the position of...

  • Please help with Q1 a)b)c). Question 1: In the lectures we considered simple projectile motion. Here we extend the description to include air resistance. For macroscopic objects in air, the dynamics...

    Please help with Q1 a)b)c). Question 1: In the lectures we considered simple projectile motion. Here we extend the description to include air resistance. For macroscopic objects in air, the dynamics equations including air resistance may be written V and ^- where m is the mass of the object, g is the acceleration due to gravity, y is the vertical direction, C is a dimensionless drag coefficient, A is the cross-sectional area of the object, pa 1.2kg/m3 is the density...

  • THE EXPERIMENT The speed "." of a ball as it leaves the spring gun will be...

    THE EXPERIMENT The speed "." of a ball as it leaves the spring gun will be measured by projecting the ball horizontally (0-0) from a table top at a distance H above the floor. The gun is then elevated at a known angle 8. The position of the target is calculated using the measured value of v. calculated time of flight, and the equations of motion. A successful prediction with the projectile hitting the target means that the following concepts...

  • MATLAB, please provide code script Objective: Create a function file that animates projectile motion defined by...

    MATLAB, please provide code script Objective: Create a function file that animates projectile motion defined by the following equations in a subplot. Your function should accept user inputs of launch speed and launch angle. The output of your function will be a top subplot that displays height (y) as a function of x. The bottom subplot should display the vertical velocity while the projectile is in motion. A video of what your animation should look like is posted with this...

  • 1. A ball of mass m is thrown with speed vo at an angle 0 with...

    1. A ball of mass m is thrown with speed vo at an angle 0 with respect to the horizontal. Let the drag force from the air take the form f Newton's second law, the r- and y-components of the acceleration of the ball are given by = mav where a is a constant and v is the speed of the ball. By du (t) = -av,(t), dt de,(t) ay(t)= -g-au,(t), dt where ug (t) and v,(t) are the x-...

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