Here is a possible implementation of the kinematics
function which takes the initial velocity and the time interval as inputs, and returns the time and displacement vectors:
main.m603 chars26 lines
You can call the function like this:
main.m34 chars2 lines
This will simulate the motion of an object starting from rest (v0=0
) with a time step of 0.1 seconds, and for a total of 100 steps (nsteps=100
). The function returns the time and displacement vectors which can be plotted using the plot
function.
gistlibby LogSnag