how to Integrate a vector ?

1 次查看(过去 30 天)
Nick van der maat
Hello,
I am trying to integrate a vector,
FuelRateINT = integrate(MAIN_EngFuelRate,MAIN_TachographVehicleSpeedTOTALROWS,1);
% MAIN_TachographVehicleSpeedTOTALROWS = number of last row
% 1 = start row
It keeps giving the error :
Undefined function 'integrate' for input arguments of type 'double'.
  1 个评论
John D'Errico
John D'Errico 2015-5-6
Note that integrate is not designed to integrate a data vector. As Star points out, use trapz or cumtrapz, depending on your goal.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2015-5-6
Use the trapz or cumtrapz functions:
FuelRateINT = trapz(MAIN_EngFuelRate,MAIN_TachographVehicleSpeedTOTALROWS);
or:
FuelRateINT = cumtrapz(MAIN_EngFuelRate,MAIN_TachographVehicleSpeedTOTALROWS);
depending upon what you want.
  2 个评论
Nick van der maat
Both of these are giving me straight zero's.
Star Strider
Star Strider 2015-5-6
That has to do with your data. Post your data (or a representative sample, preferably as a .mat file). It is impossible to figure out the problem without them.

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by