How to use 'trapz' command to calculate the area under the curve for each time gap of a graph?

조회 수: 1 (최근 30일)
T Y
1.00 2988.00
1.00 2966.00
1.00 2915.00
1.00 2891.00
1.00 2833.00
1.02 2846.00
1.19 2829.00
1.39 2799.00
1.66 2806.00
1.80 2804.00
2.00 2834.00
2.19 2827.00
2.39 2897.00
2.66 2889.00
2.80 2864.00
3.02 2874.00
3.19 2890.00
3.39 2874.00
3.64 2964.00
3.80 3059.00
4.02 3109.00
4.19 3214.00
4.39 3292.00
4.66 3334.00
4.80 3443.00
5.00 3515.00
5.19 3614.00
5.39 3736.00
5.66 3789.00
5.80 3811.00
6.00 3892.00
6.20 3954.00
6.41 3985.00
6.66 4039.00
6.80 4039.00
7.00 4045.00
7.19 4040.00
7.39 3977.00
7.66 3918.00
7.80 3961.00
8.02 3955.00
8.19 3923.00
8.39 3988.00
8.66 4064.00
8.80 4001.00
9.00 3991.00
9.19 4043.00
9.39 4021.00
9.66 3970.00
9.80 3967.00
10.00 3932.00
10.19 3856.00
10.39 3794.00
10.66 3782.00
10.80 3726.00
11.00 3688.00
11.19 3642.00
11.39 3584.00
11.66 3512.00
11.80 3398.00
12.02 3322.00
12.19 3222.00
12.39 3145.00
12.66 3098.00
12.80 3144.00
13.02 3134.00
13.19 3137.00
13.41 3175.00
13.64 3152.00
13.80 3095.00
14.02 3062.00
14.19 3046.00
14.39 3010.00
I have a data set like above, I used 'trapz' command to calculate the area under the curve. Using that, we can calculate the total area. my question is can anybody help me to do the area under the curve calculation related to each time gap? if we can't use trapz command can we use the 'int' command?
Thanks in advance

답변 (1개)

Torsten
Torsten 2016년 6월 22일
편집: Torsten 2016년 6월 22일
for k=1:length(T)-1
area(k)=0.5*(Y(k)+Y(k+1))*(T(k+1)-T(k));
end
area(k) gives you the area under the graph between T(k) and T(k+1).
Best wishes
Torsten.

카테고리

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