How to calculate the area under the curve for each time gap using "trapz" command?

1 次查看(过去 30 天)
I wanted to calculated the area under the curve of X vs T graph.
Here is the data set:
disp([T(:,5),X(:,5)])
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
then I used "trapz" command to calculate the area under the curve.
totalcounts=trapz(T(:,5),X(:,5))
But, now I need to calculate the area under the curve for each time period ( for each time gap). I would be greatful, if anyone can guide me.
Thanks in advance.

采纳的回答

Torsten
Torsten 2016-8-1
area(1:N-1)=0.5*(X(1:N-1,5))+X(2:N,5))*(T(2:N,5)-T(1:N-1,5))
Best wishes
Torsten.
  4 个评论
Torsten
Torsten 2016-8-2
编辑:Torsten 2016-8-2
Should read:
N=size(T,1);
area(1:N-1)=0.5*(X(1:N-1,5)+X(2:N,5)).*(T(2:N,5)-T(1:N-1,5))
Sorry.
Best wishes
Torsten.

请先登录,再进行评论。

更多回答(0 个)

类别

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