derive v(y) = v0 * (1-(y/t).^4).^2 in matlab

You can write a function in Matlab to derive the equation v(y) = v0 * (1-(y/t).^4).^2 as follows:

main.m
function v = velocity(y, v0, t)
% Calculates velocity v(y) as a function of height y
% v0 is the initial velocity
% t is the time taken to reach the maximum height

v = v0 * (1 - (y/t).^4).^2;
end
197 chars
8 lines

In this function, y, v0, and t represent the height, initial velocity, and time taken to reach the maximum height, respectively.

To use this function, simply call it with appropriate values of y, v0, and t:

main.m
% Calculate velocity at a height of 10 meters with initial velocity 20 m/s, and time taken to reach the maximum height 2 seconds
v = velocity(10, 20, 2)
153 chars
3 lines

This will return the value of v at a height of 10 meters.

gistlibby LogSnag