How to integrate imported data with specified limits.

조회 수: 8 (최근 30일)
Jordon Dobson
Jordon Dobson 2022년 10월 5일
댓글: M Herper 2022년 10월 5일
Hi,
I am studying switchies losses during swithcing transients of certain devices. I have imported the swithcing data from a different software an uploded it into MATLAB. I am trying to calcuate the area under the curve from the data that has been imported. I have used the Trapz rule and can find out the area under the whole curve, however when I am struggling to apply limits.
I have also looked at the integration Funciton however, I dont know how to run my waveform into a specific function.
I have included the full wavform, and then a section of it, which I wish to calculate the area under.
Thanks,
J
  댓글 수: 1
M Herper
M Herper 2022년 10월 5일
Hi,
trapz integrates the whole array, so you can create a subset of the array to be integrated.
Here a little code sample:
lower_limit = 2;
upper_limit = 4;
stepsize = 1;
t = lower_limit:stepsize:upper_limit;
raw_data = [1 1 1 1 1 1 1 1]
data_to_be_integrated = raw_data(lower_limit:upper_limit)
trapz(t, data_to_be_integrated) % ans = 2
cumtrapz(t, data_to_be_integrated) % ans = 1x3: 0 1 2

댓글을 달려면 로그인하십시오.

답변 (1개)

Jiri Hajek
Jiri Hajek 2022년 10월 5일
If you data is e.g. X,Y, both vectors 1:N, you can create suitable subinterval by assigning Xsub = X(i1:i2), Ysub = Y(i1:i2) and then applying the trapz function on these new data vectors.

카테고리

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