필터 지우기
필터 지우기

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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical 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