1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
PtichkaEL [24]
3 years ago
8

g % 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.
Computers and Technology
1 answer:
Gala2k [10]3 years ago
7 0

Answer:

% 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 all

close all

clc

velStart=input('input the initial velocity in m/sec:   ');

angle=20:5:80;

% convert the degrees into radians so MATLAB likes it

values_angle=angle*pi./180;

rangeAngle=length(values_angle);

hold on

%Lines 1 - 14 are fine

for i=1:rangeAngle

% set initial position and time

x=[];

y=[];

time=[];

vel=velStart;

VelocityX=[];

VelocityY=[];

x(1)=0; % meters

y(1)=.001;  % 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 where Re is between 10^3 and 10^5

% so I can load an array for plotting

% start to increment the motion

 

index=1;

thisAngle=values_angle(i);

velx=vel*cos(thisAngle);

VelocityX(1)=velx;

vely=vel*sin(thisAngle);

VelocityY(1)=vely;

% set a time step

deltaTime=.001; % seconds

height=y(1);

flag=0;

velFinalX = 0;

velFinalY = 0;

%Don't see any issues here

while height>0 % check that the ball has not hit ground yet (1e-3 to speed things up, It hangs because it never leaves this line, check how height is calculated.)

   index = index+1;

   

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

   % break velocity into its components

   if index == 2

       velx = vel*cos(thisAngle);

       vely = vel*sin(thisAngle);

   else

       velx = velFinalX;

       vely = velFinalY;

   end

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

   

   

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

   % 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.

   if vely < 0

       adragy = g + (c*vely.^2)/mass;

       velFinalY = vely + adragy.*deltaTime;

   else

       adragy = g - (c*vely.^2)/mass;

       velFinalY = vely + adragy.*deltaTime;

   end

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

   

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

   % Now calculate the acceleration in the x .

   adragx = (-c*velx.^2)/mass;

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

   

   

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

   % 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.

   velFinalX = velx + adragx.*deltaTime;

%     velFinalY = vely + adragy.*deltaTime;

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

   

   

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

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

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

   vel = sqrt(velFinalX.^2 + velFinalY.^2);

   angle = atan(velFinalY/velFinalX);

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

   

   % now save my values at this time step

   VelocityX(index)=velFinalX;

   VelocityY(index)=velFinalY;

   

   % and distance numbers

   distX=VelocityX(index).*deltaTime;

   distY=VelocityY(index).*deltaTime;

   

   % save distance values  

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

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

   height=y(index);

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

   %lines 105-107 are good

   if distY<0&&flag<=1

       if height<.25

           disp(distY)

           fprintf('goal height detected at distance %.2f meters.',x(index));

           flag =2;

           LandingDistance(i)=x(index);

       end

   end

   

end

plot(x,y)

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

xlabel('horizontal distance traveled (meters)')

ylabel('vertical distance traveled (meters)')

end

hold off

Explanation:

You might be interested in
Which of the following statements is false?
Sergio039 [100]

Answer:

Option (d)

Explanation:

Option (a) the return type of the method specifies the type of the data that is returned for the method calling. The return type can be void if it doesn't return any value. The method return can be int, string and bool etc. So, option (a) is true and it not the correct option.

Option (b) is true it doesn't need any parameters. So, option (b) is not the correct option.

Option (c) is true. If the method has some return type other than void it must return something according to the return type.So, option (c) is not the correct option.

Option (d) is false. Getters and setters methods are used for accessing private variables but the name MUST start with get or set is false. The best practice is to start with get and set but it is NOT a must.

So, option (d) is correct option.

6 0
3 years ago
The Internet is considered a WAN. *<br><br> True<br> False
nlexa [21]

Answer:

true-ish

Explanation:

WAN= wide area network

LAN= local area network

it could be considered a wide area network, but not necessarily. The internet is it's own type of connection, so I'm not quite sure if it would be considered something else or WAN.

4 0
2 years ago
Rounding up and down for 389,422
elena-14-01-66 [18.8K]

Answer:

389420

389430

Explanation:

the up is for 389430

the down is for 389420

4 0
3 years ago
How to print<br> 1<br> 321<br> 54321<br> 7654321<br> triangle pattern in python
krok68 [10]

Hope this helps, Upvote if you like it :)

6 0
2 years ago
Which is the default scripting language in most browsers? A. ASP B. JavaScript C. PHP D. XML
vodomira [7]

Answer:

Javascript

Explanation:

Ive learned about it and its the most known one.

4 0
3 years ago
Other questions:
  • 1.
    13·1 answer
  • Which of the following are you likely to find between multiple school buildings in a city wide school district?
    9·1 answer
  • How many electrons are there in an atom of carbon? A. Four B. Eight C. Six D. One
    15·2 answers
  • Which term is used to describe a password-protected, encrypted data file that verifies the identity of the sender of a message?
    8·1 answer
  • Which of the following statements about electronic cover letters is true?
    14·2 answers
  • Hurry im TIMED
    8·1 answer
  • Describe how a cell’s content and format attributes are related.
    13·2 answers
  • Wearables, video playback and tracking devices can help athletes because
    15·1 answer
  • Why is lateral reading an important tool when reading material in social media or any online source
    15·1 answer
  • What is are the most efficient ways to make a slide presentation?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!