Here's one way you can make an object jump in Matlab using the plot
function:
main.m702 chars26 lines
You can adjust the jumpHeight
and jumpLength
variables to change the height and length of the jump, respectively. The sin
functions are used to make the jump smooth and realistic. The t<jumpLength
and t>=2*jumpLength
expressions are used to make the object stay at its initial and final positions, respectively, for a brief moment before and after the jump.
gistlibby LogSnag