How to Use Numerical Integration
Show older comments
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??
Answers (1)
Star Strider
on 25 May 2016
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 Comments
Victoria Lucero
on 25 May 2016
Star Strider
on 25 May 2016
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.
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!