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??

Respuestas (1)

Star Strider
Star Strider el 25 de Mayo de 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 comentarios

Victoria Lucero
Victoria Lucero el 25 de Mayo de 2016
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);
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.

Iniciar sesión para comentar.

Categorías

Preguntada:

el 25 de Mayo de 2016

Comentada:

el 25 de Mayo de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by