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 ):
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:6| Question number:29.6
All Answers
total answers (1)
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