To find displacement from acceleration and time using calculus in Matlab, we need to integrate the acceleration with respect to time twice. Here is the code that demonstrates this:
main.m420 chars15 lines
In the code, we first define the acceleration and time vectors, and then we use the built-in cumtrapz
function to integrate the acceleration vector to get velocity (v
), and then integrate the velocity to get displacement (s
). Finally, we plot the displacement graph against time using the plot
function.
gistlibby LogSnag