numerical integration in matlab

2 visualizaciones (últimos 30 días)
parham kianian
parham kianian el 12 de Abr. de 2020
Respondida: David Hill el 12 de Abr. de 2020
Suppose A is a column vector whose arrays are acceleration of a moving object and each array has been sampled every 0.01 sec.
I want to numerically integrate A to evaluate the velocity time history of object. I did the following:
t = (0 : 0.01 : 0.01 * (length(A) - 1));%time as a column vector
V = zeros(size(A));%initiate velocity vector
for ii = 1 : length(A) - 1
V(ii+1) = V(ii) + trapz(t(ii:ii+1),A(ii:ii+1));
end
The above code works well but I have hundereds of acceleration vectors and peforming calculation using "for loop" is too much time consuming.
Is there any function in matlab to integrate without "for loop" over vectors?

Respuesta aceptada

David Hill
David Hill el 12 de Abr. de 2020
cumtrapz()

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by