how to intergrate my acceleration vs time curve to velocity vs time curve with simpson's rule, instead of using cumtrapz?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
CHUNG CHIEH GAN
el 12 de Abr. de 2020
Respondida: Thiago Henrique Gomes Lobato
el 12 de Abr. de 2020
i have a data set of acceleration vs time, i need to intergrate it into velocity vs time and also displacement vs time. anyone can help me with numerical simpson's rule instead of using cumtrapz?
0 comentarios
Respuestas (1)
Thiago Henrique Gomes Lobato
el 12 de Abr. de 2020
You need to implement the simpson's rule on your own. A naive implementation would be something like that
f = @(t)t.^2;
N = 1000;
ti = 0;
tend = 5;
h=(tend-ti)/N;
t=linspace(ti,tend,N);
F = 0;
for i = 1:N-1
F = F + (h/6)*(f(t(i))+(4*f((t(i)+t(i+1))/2))+f(t(i+1)));
end
% To verify the result
AnalyticalResult = tend^3/3;
Error = (AnalyticalResult-F)/AnalyticalResult
Error =
1.0000e-03
0 comentarios
Ver también
Categorías
Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!