Effacer les filtres
Effacer les filtres

How can i integrate an array using the trapz function

8 vues (au cours des 30 derniers jours)
Tariq Hammoudeh
Tariq Hammoudeh le 3 Mar 2023
If i have the following data
time=[1 2 3 4 5] %time in seconds
acceleration=[1.1 1.2 1.3 1.4 1.5]
Then how can I integrate acceleration and get the velocity at every second in the form of an array.
I tried v=trapz(acceleration);
but that just integrates acceleration and returns a single value

Réponse acceptée

Torsten
Torsten le 3 Mar 2023
Déplacé(e) : Torsten le 3 Mar 2023
Use cumtrapz instead.
  3 commentaires
Torsten
Torsten le 3 Mar 2023
Modifié(e) : Torsten le 3 Mar 2023
Believe me: cumtrapz(time,acceleration) gives you the velocity field V with initial value V(time(1)) = 0.
If you do
(second element-first element)/time
you differentiate. But velocity is acceleration integrated.
Tariq Hammoudeh
Tariq Hammoudeh le 3 Mar 2023
oh I got it now thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by