フィルターのクリア

How can I compute Trapezoidal numerical integration (Q = trapz(X,Y), while my X is a datetime-lalue vector?

3 ビュー (過去 30 日間)
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!

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 1 月 27 日
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 件のコメント
ADJE JEREMIE ALAGBE
ADJE JEREMIE ALAGBE 2021 年 1 月 27 日
Thank you so much, Dear Mathieu. It works perfectly. God bless you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by