How can I compute Trapezoidal numerical integration (Q = trapz(X,Y), while my X is a datetime-lalue vector?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
ADJE JEREMIE ALAGBE
le 27 Jan 2021
Commenté : Mathieu NOE
le 27 Jan 2021
Hi everyone, I am trying to calculate the integrale of Y vector ( some observation values) with respect to x-coordinates (datetime values) (see volumes.xlsx file). the column of Y represent volume data, taken at the times contained in X, that take place at 3 minute-intervals, for one day. How can I do that to get a result of integral that is a number, not a time-format value? For example I got sometime this:
Q = trapz(X,Y)
Q =
duration
153:03:00
but I want a result that is number, for example 10.
Any idea to help? Thanks everyone!
0 commentaires
Réponse acceptée
Mathieu NOE
le 27 Jan 2021
hello
see below , depends if integral must be done on seconds or minutes time stamps - you to choose !
T = readtable('volumes.xlsx') ;
data = cellfun(@double,table2cell(T(:,2)));
% extraction of minutes time vector from date vector
dd = datenum(T{:,1}); % expressed in unit "days"
dd = dd - dd(1); % vector must start at zero
time_minutes = dd*24*60;
time_seconds = time_minutes*60;
% do the trapz integration
Int_vol_minutes = trapz(time_minutes,data)
Int_vol_seconds = trapz(time_seconds,data)
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!