need help with the following code below. I labeled where i need help and where it ends. I also explained in the code what i need help with.       EDIT THIS CODE:    % 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.   clear clc     vel=input('input the initial velocity in m/sec: '); angle=input('input the angle of launch in degrees: '); % convert the degrees into radians so MATLAB likes it   angle=angle*pi/180;   % set initial position and time 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 velx=vel*cos(angle); VelocityX(1)=velx; vely=vel*sin(angle); VelocityY(1)=vely; % set a time step deltaTime=.001 % seconds height=y(1); while height>=0 % it has not hit ground yet index=index+1; % break velocity into its components velx=vel*cos(angle); vely=vel*sin(angle);   % NEED HELP HERE START % 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. Calculated the acceleration % in the y direction inside the if/else statement. % 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" % NEED HELP HERE END   % 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)')

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Need help with 3 parts on this code. Please edit my code, don't create a different code. 
 
I need help with the following code below. I labeled where i need help and where it ends. I also explained in the code what i need help with.
 
 
 
EDIT THIS CODE: 
 
% 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.
 
clear
clc
 
 
vel=input('input the initial velocity in m/sec: ');
angle=input('input the angle of launch in degrees: ');
% convert the degrees into radians so MATLAB likes it
 
angle=angle*pi/180;
 
% set initial position and time
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
velx=vel*cos(angle);
VelocityX(1)=velx;
vely=vel*sin(angle);
VelocityY(1)=vely;
% set a time step
deltaTime=.001 % seconds
height=y(1);
while height>=0 % it has not hit ground yet
index=index+1;
% break velocity into its components
velx=vel*cos(angle);
vely=vel*sin(angle);
 
% NEED HELP HERE START
% 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. Calculated the acceleration
% in the y direction inside the if/else statement.
% 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"
% NEED HELP HERE END
 
% 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)')
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY