Edit: MATLAB. I'm trying to create a function which returns an array of the velocity per second for a free falling object. The input argument for the function is the height h. Also, if the object hits the ground before 1 second, it should return the velocity for the time it hits the ground.
Example: If the object falls from 80 meters, the function should return
v =
9.8 19.6 29.4 39.2
My attempt looks like this:
function freefall(h)
g = 9.8; % gravity acceleration
h_t = linspace(0,h); % the height should start from 0 to input height h
t = sqrt(2.*h_t/g); % time for the free fall
n=0;
if t < 1
velocity = sqrt(2*g*h)
disp(velocity)
else
for time = n+1 % An attempt to try making t into integers(tried floor(t) but didn't work)
v = g.*time
while time <= t % Don't want the time to exceed the amount of time it takes for object to land
disp(v)
end
end
end
end
The output just becomes v = 9.82, and I'm out of ideas to try and make this work.