How to Use Numerical Integration

How do you do numerical integration for the velocity when given the time and acceleration? I also know that this data is first recorded when the rocket has a velocity, vi, of -250 m/s and that the integral of acceleration is velocity. Using numerical integration, I need to calculate the velocity as a function of time. the data is taken every .001 seconds. below is what I have coded so far and attached is the data excel sheet.
%% Data
data = xlsread('Rocket.xls');
t = data(:,1);
a = data(:,2);
%% Rockets Velocity??

回答 (1 件)

Star Strider
Star Strider 2016 年 5 月 25 日

0 投票

If your data are vectors, use the cumtrapz or trapz function, depending on what result you want.
For example:
v = cumtrapz(t, a); % Calculate Velocity
d = cumtrapz(t, v); % Calculate Displacement

2 件のコメント

Victoria Lucero
Victoria Lucero 2016 年 5 月 25 日
I got this error:
Error using cumtrapz (line 71) LENGTH(X) must equal the length of Y in dim 1.
Error in P4 (line 27) v = cumtrapz(t, a);
Star Strider
Star Strider 2016 年 5 月 25 日
I don’t have your data, so I assumed they were the same lengths.
You would first have to shorten the longer vector, and since I don’t know which one that is, I have to generalise.
Do this first:
L = min(length(t),length(a));
a = a(1:L);
t = t(1:L);
then do the integrations.

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

カテゴリ

質問済み:

2016 年 5 月 25 日

コメント済み:

2016 年 5 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by