Why I get different values when I integrate a function (by my hand, cumtrapz)?
As you can see below, there is a very big difference when I integrate the function with cumtrapz.
%% Simple
t = 0:1:5; % Time (s)
a = 10*cos(20*t); % Acceleration (m/s^2)
VALUES:104,08082061813392-6,66938061652262-9,52412980415156-1,103872438390488,62318872287684v = sin(20*t)/2; % Velocity (m/s)
VALUES:00,4564726253638140,372556580239674-0,152405310551108-0,496944326961688-0,253182820554879x = -cos(20*t)/40; % Displacement (m)
VALUES:-0,0250000000000000-0,01020205154533480,01667345154130650,02381032451037890,00275968109597619-0,0215579718071921
%% Cumtrapz
t = 0:1:5; % Time (s)a_cumtrapz = 10*cos(20*t); % Acceleration (m/s^2) with Cumtrapz
VALUES:104,08082061813392-6,66938061652262-9,52412980415156-1,103872438390488,62318872287684v_cumtrapz = cumtrapz(t,a_cumtrapz); % Velocity (m/s) with Cumtrapz
VALUES:07,040410309066965,74613030987261-2,35062490046448-7,66462602173550-3,90496787949232x_cumtrapz = cumtrapz(t,v_cumtrapz); % Displacement (m) with Cumtrapz
VALUES:03,520205154533489,9134754640032711,61122816870736,603602707607340,818805756993430
Best Answer