Please solve this Matlab question showing short inputs. Thank you for your help.
ID: 3572084 • Letter: P
Question
Please solve this Matlab question showing short inputs. Thank you for your help.
Create a function called launch (show that separately) that takes an input argument from main program that is a range of time of 0 to 22 seconds with an increment of 2 seconds. The function has one output argument that is a table that consists of time and y. Call this function from the main program of this quiz. Initialize variables for the initial velocity, v0=108, and gravity, g=9.81, in your function and use in the general formula below. All the units are metric, so don't worry about units. General formula: y = _v0t - (1/2) gt^2Explanation / Answer
% matlab code
function y = launch (time)
g = 9.81;
v0 = 108;
for i=1:length(time)
y(i) = v0*time(i)-0.5*g*time(i)*time(i);
end
end
time = linspace(0,22,12);
disp("TIME: ");
disp(time);
y = launch(time);
disp("Y: ");
disp(y);
%{
output:
TIME:
0 2 4 6 8 10 12 14 16 18 20 22
Y:
0.00000 196.38000 353.52000 471.42000 550.08000 589.50000 589.68000 550.62000 472.32000 354.78000 198.00000 1.98000
%}