Question

In: Mechanical Engineering

MATLAB 2017b The trajectory of a projectile is given by: Write a program which will draw...

MATLAB 2017b

The trajectory of a projectile is given by:

Write a program which will draw the trajectory for seconds. Make sure to label, title and grid your graph.

Solutions

Expert Solution

 clear 
 close all
 disp('Welcome to the Projectile Motion Plotter');
 disp('This projects the motion for a tennis ball with and without air resistance');
 Vx = input('Please input the horizontal velocity [m/s]: ');            
 Vy = input('Please input the vertical velocity [m/s]: ');              
 %Sets up intial conditions
  V = sqrt(Vx^2 + Vy^2);   %Determines V by combining v of both axes 
  G = 9.80665;             %m/s^2 Acceleration due to Gravity       
  DC = 0.8;                %Drag coefficient
  Area = 0.0033;           %m^2 cross section area of a tennis ball
  Mass = 0.057;            %Kg mass of tennis ball
  x(1) = 0;                %intial x postion
  y(1) = 0;                %inital y postion
  xf(1) = 0;               %inital xf postion
  yf(1) = 0;               %intial yf postion
  AP = 1.2;                %kg/m^3 Air Density @ Sea  Level
  D = AP*DC*Area/2;        %constant needed for drag calculations created    
  t(1) = 0;                %sets intial time
  dt = 0.01;               %s set the intervals at which time will be evalutated
  i = 1;                   %sets counter/index
 %Starts a loop for Projectile Motion with Drag    
    while min(y)> -0.01;                                          
       t = t + dt;                                               
       i = i + 1;                                                
       xf(i) = xf(i-1)+ Vx.*dt;                                  
       AxD = - ( D / Mass ) * V * Vx;                            
       AyD = -G - ( D / Mass ) * V * Vy;                         
       Vx = Vx + AxD * dt;                                       
       Vy = Vy + AyD * dt;                                       
       x(i) = x(i-1) + Vx * dt + 0.5 * AxD * dt^2;               
       y(i) = y(i-1) + Vy * dt + 0.5 * AyD * dt^2;               
   end;
 plot(x,y,'b'), hold on;               %plots the Projectile Motion with Drag
 plot(xf,y,'r'), hold off;             %plots the Projectile Motion without Drag
 xlabel('Horizontal Distance (m)');    %labels the x axis "Horizontal Distance (m)"
 ylabel('Vertical Distance (m)');      %Labels the y axis "Vertical Distance (m)"
 title('Projectile Motion Paths');     %Gives a Title "Projectile Motion Paths"

Related Solutions

Hi, I'm currently writing a Matlab program to simulate the Apollo 11 trajectory. Now I want...
Hi, I'm currently writing a Matlab program to simulate the Apollo 11 trajectory. Now I want to plot a 3D animated orbit which is a 60 by 58 nautical miles orbit. Can you provide a code or some idea of how to plot an orbit like this in 3D?
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.
MATLAB Write a script which asks the user of the program to provide an initial horizontal...
MATLAB Write a script which asks the user of the program to provide an initial horizontal position, initial vertical position, initial velocity, and angle. Create a time vector spanning from zero seconds to 100 seconds incremented at 0.01 seconds. Call the function that you created in the previous problem to calculate the trajectory and velocities of the projectile. Find the maximum height of the projectile and the time at which it reaches that point. Write a neat sentence stating what...
In python. Projectile motion: Write a python program that will ask the user for      an...
In python. Projectile motion: Write a python program that will ask the user for      an initial height y0, initial velocity v, launch angle theta, and mass m.      Create two functions, one that will calculate max height      of the projectile, and one that will calculate the range. Ask the     user which one he/she would like to calculate, then present them with the answer. (use kg, m and m/s)
USE MATLAB Write a program in Matlab that would continuously ask the user for an input...
USE MATLAB Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user. If the user’s die is larger, it should display, “Mahahanap mo na ang forever mo. Sana all!” If the user’s die is smaller, it should display, “Gising na friend,...
Write a program (MATLAB) which generates exponential random variables, and use it to test the Central...
Write a program (MATLAB) which generates exponential random variables, and use it to test the Central Limit Theorem as follows. For various values of n (say, 5, 10, 20, 50, 100, 1000), generate samples of the random variable Mn = 1/n \tiny \sum Xi where Xi are iid exponential random variables. A very simple method for generating exponential random variables is given on page 196 of the textbook (read that section). Plot the discretized CDF for Mn (an approximation of...
Using MatLab Write a program which will: a. Accept two numbers from the user m and...
Using MatLab Write a program which will: a. Accept two numbers from the user m and n b. Define an array with the dimensions a(n,m) and fill it with random numbers in the range of -100 to 100 inclusive. c. Accept from the user two row numbers. Multiply the two rows (element by element) and find the sum. Print the result. d. Accept from the user two column numbers. Add the two columns (element by element) and find the sum....
I need to find the trajectory of a projectile launched at 1000 m/s at 45 degrees...
I need to find the trajectory of a projectile launched at 1000 m/s at 45 degrees to the horizontal, launched in an easterly direction from a point on the equator. I have to assume that it is a lead sphere of radius r = 5cm. Also, what is the distance of the landing point from the launch point? Including the effects of the coriolis force and the effects of linear and quadratic air resistance. What would this trajectory look like?...
Write a user defined MATLAB program that performs power factor correction. The inputs to the MATLAB...
Write a user defined MATLAB program that performs power factor correction. The inputs to the MATLAB function should be voltage across the load (in Vrms, assume 0 phase), frequency Resistance of the load Inductance of the load power factor of the load target power factor The output of the function should be the size of the capacitor that one would need to place in parallel with the load to reach the target power factor. Please submit the code for the...
Write a program in Matlab where the program plays a hot and cold game. The user...
Write a program in Matlab where the program plays a hot and cold game. The user answers two inputs: x=input('what is the x location of the object?') y=input('what is the y location of the object?') You write the program so that the computer plays the game. Pick a starting point. Program Calculates the distance to the object. Program picks another point, calculates the distance to the object. Program knows its at the right spot when the distance is less than...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT