Q:

Write a program to calculate the position of a projectile at a given time t. For an initial velocity v0 and angle of departure θ0, the position is given by x and y coordinates as follows (note: the gravity constant g is 9.81m/s2 ):

0

 Write a program to calculate the position of a projectile at a given time t. For an initial velocity v0 and angle of departure θ0, the position is given by x and y coordinates as follows (note: the gravity constant g is 9.81m/s2 ):

The program should initialize the variables for the initial velocity, time, and angle of departure. It should then call a function to find the x and y coordinates, and then another function to print the results. If you have version R2016a or later, make the script into a live script.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch6Ex29.m

% Projectile motion

v0 = 33;

theta0 = pi/4;

[x, y] = findcoords(v0, theta0, t);

printcoords(x,y)

findcoords.m

function [x, y] = findcoords(v0, theta0, t)

g = 9.81;

x = v0 * cos(theta0) * t;

y = v0 * sin(theta0) * t - 0.5 * g * t * t;

end

printcoords.m

function printcoords(x,y)

fprintf('x is %f and y is %f\n', x, y)

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now