Using For Loop to integrate acceleration data to get velocity and displacement

4 ビュー (過去 30 日間)
tupac1971ful
tupac1971ful 2016 年 5 月 20 日
コメント済み: Star Strider 2016 年 5 月 28 日
So I'm a new user to matlab and I have problem understanding the for_loop. I have some acceleration data with its respective time from my accelerometer with a sample frequency f=10Hz starting measuring at t0= 0s, tf = 15s. (15 seconds of 150 measurements)
" t = xlsread('odostroma.xlsx','A1:A150'); %time data a = xlsread('odostroma.xlsx','B1:B150'); " %acceleration data
I want to get my values from the equations v=a*t+v0 , x = 1/2*a*t^2+v*t+x0 Can someone give me the code or the instructions to do so with forloop? And to begin with, is this the right way to get velocity/displacement at its specific time value? I don't want to use the cumtrapz function to integrate,just wanting to know if this can work and if not then why. but I still want forloop just to get the understanding of it

回答 (1 件)

Star Strider
Star Strider 2016 年 5 月 20 日
Forget the for loop.
Use the cumtrapz function once to get velocity, and twice (once on the velocity vector) to get displacement.
  2 件のコメント
tupac1971ful
tupac1971ful 2016 年 5 月 28 日
I know how to use the cumtrapz function, just wanting to get velocity with for loop so I can also understand how it works but also to get the exact results.
Star Strider
Star Strider 2016 年 5 月 28 日
Using a for loop is just summing the trapezoidal segments of the function. Tired tonight (long week) so I’ll vector you to the Wikipedia article on Trapezoidal integration. The section on the uniform grid is particularly straightforward. It’s just an iterative sum, with the function evaluated at each element of the grid.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by