Question

In: Electrical Engineering

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.

Solutions

Expert Solution

clc;
close all;
clear all;

v0 = 20; % Initial velocity is 10 m/s
theta = 45 ; % Launch angle in degrees

vx0 = v0 * cos (theta*pi/180); % the initial velocity along the x-axis is vx0
vy0 = v0 * sin (theta*pi/180); % the initial velocity along the y-axis is vy0

t = 0:0.01:3; % time
g = 9.8;% acceleration due to gravity is g
vx = vx0; % the velocity along the x-axis is vx ,
x = vx * t; % Horizontal distance
y = vy0 .*t - 1/2* g * t.^2; % Vertical distance

% for k = 1:length(t)
% if y(k)<-0.1
% y(k) = 0;
% x(k) = 0;
% end
% end

figure;plot(t,x);grid;xlabel('time (seconds)');ylabel('x - distance (m)');title('t vs x');
figure;plot(t,y);grid;xlabel('time (seconds)');ylabel('y - distance(m)');title('t vs y');

figure;plot(x,y);grid;xlabel('x - distance (m)');ylabel('y - distance (m)');title('x vs y');


Related Solutions

Consider the projectile motion of two balls. Ball A is launched horizontally (no vertical component of...
Consider the projectile motion of two balls. Ball A is launched horizontally (no vertical component of velocity) with an initial speed of 100 m/s from an initial position 1 m above the ground. Ball B is launched straight upward (no horizontal component of velocity) with an initial speed of 1 m/s from an initial position 0.5 m above the ground. The two balls are launched at the same time. Assume that air resistance doesn’t matter in this problem and assume...
Consider the projectile motion of two balls. Ball A is launched horizontally (no vertical component of...
Consider the projectile motion of two balls. Ball A is launched horizontally (no vertical component of velocity) with an initial speed of 100 m/s from an initial position 1 m above the ground. Ball B is launched straight upward (no horizontal component of velocity) with an initial speed of 1 m/s from an initial position 0.5 m above the ground. The two balls are launched at the same time. Assume that air resistance doesn’t matter in this problem and assume...
Projectile Motion A projectile, launched over level ground from a height of 450 meters above the...
Projectile Motion A projectile, launched over level ground from a height of 450 meters above the flat sur face below, has an initial speed of 175 m/s . The projectile is launched at a 43.5 degree angle in relation to the horizontal direction a What are the initial horizontal and vertical components of the velocity of the projec tile? bIn terms of the initial horizontal and vertical components of the velocity, write down equations for the motion of the x...
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)
Please solve the following problem for MATLAB Write a user-defined function that calculates the average and...
Please solve the following problem for MATLAB Write a user-defined function that calculates the average and the standard deviation of a list of numbers. Use the function to calculate the average and the standard deviation of the following list of grades : 80 75 91 60 79 89 65 80 95 50 81
Please solve the following problem for MATLAB Write a user-defined function (name it F to C)...
Please solve the following problem for MATLAB Write a user-defined function (name it F to C) that converts temperature in degrees F to temperature in degrees C. Use the function to solve the following problem. The change in the length of an object, ∆L, due to a change in the temperature, ∆T, is given by: ∆L = αL∆T, where a is the coefficient of thermal expansion. Determine the change in the area of a rectangular(4.5 m by 2.25m) aluminum (α=23·10-61/˚C)...
Write a user-defined MATLAB function, with two input and two output arguments that determines the height...
Write a user-defined MATLAB function, with two input and two output arguments that determines the height in centimeters (cm) and mass in kilograms (kg)of a person from his height in inches (in.) and weight in pounds (lb). (a) Determine in SI units the height and mass of a 5 ft.15 in. person who weight 180 lb. (b) Determine your own height and weight in SI units.
Write a user-defined MATLAB function that converts real numbers in decimal form to binary form. Name...
Write a user-defined MATLAB function that converts real numbers in decimal form to binary form. Name the function b = deciTObina (d), where the input argument d is the number to be converted and the output argument b is a 30-element-long vector with 1s and 0s that represents the number in binary form. The first 15 elements of b store the digits to the left of the decimal point, and the last 15 elements of b store the digits to...
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...
Q.3. Projectile Motion (30) A projectile is launched at 40.0 m/s at an angle 30 degree...
Q.3. Projectile Motion (30) A projectile is launched at 40.0 m/s at an angle 30 degree from ground to ground. o Write a function that will return the time of flight based on V_{0} and theta. o Find N time split (suppose N=20) and put those time in Tf[]. o Calculate the height y of the projectile for those time and put them in Y[]. Language C++ code
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT