How can i integrate an array using the trapz function

8 次查看(过去 30 天)
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

采纳的回答

Torsten
Torsten 2023-3-3
移动:Torsten 2023-3-3
Use cumtrapz instead.
  3 个评论
Torsten
Torsten 2023-3-3
编辑:Torsten 2023-3-3
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by