How can i determine the area below a plotted graph?

1 次查看(过去 30 天)
I have plot the rows of a matrix A[7x24] and a matrix B[7x24] in respect to a vector C[1x24]
I would like to find a vector D1 with the area below each graph as elements and then evaluate the sum of al the areas
I've tried with this scritp but t dosent work.
A=[ 0.6495 0.7393 0.7551 0.7947 0.7974 0.8713 1.0482 1.2621 1.6027 1.7189 1.5710 1.3070 1.4416 1.5684 1.6080 1.6053 1.6581 2.2865 2.4925 2.6087 2.3288 2.1941 1.9671 1.6265;
0.7210 0.8207 0.8383 0.8823 0.8852 0.9673 1.1636 1.4010 1.7792 1.9081 1.7440 1.4509 1.6004 1.7411 1.7850 1.7821 1.8407 2.5383 2.7669 2.8959 2.5852 2.4357 2.1836 1.8055;
0.7314 0.8324 0.8503 0.8949 0.8979 0.9811 1.1803 1.4211 1.8046 1.9354 1.7689 1.4716 1.6233 1.7660 1.8106 1.8076 1.8671 2.5746 2.8065 2.9373 2.6222 2.4706 2.2149 1.8314;
0.7351 0.8366 0.8546 0.8994 0.9024 0.9860 1.1862 1.4283 1.8137 1.9452 1.7779 1.4791 1.6315 1.7749 1.8197 1.8167 1.8765 2.5876 2.8207 2.9522 2.6354 2.4830 2.2261 1.8406;
0.7351 0.8366 0.8546 0.8994 0.9024 0.9860 1.1862 1.4283 1.8137 1.9452 1.7779 1.4791 1.6315 1.7749 1.8197 1.8167 1.8765 2.5876 2.8207 2.9522 2.6354 2.4830 2.2261 1.8406;
0.7336 0.8350 0.8529 0.8976 0.9006 0.9841 1.1839 1.4254 1.8101 1.9413 1.7743 1.4761 1.6282 1.7713 1.8160 1.8131 1.8727 2.5824 2.8150 2.9462 2.6301 2.4781 2.2216 1.8369;
0.7100 0.8081 0.8254 0.8687 0.8716 0.9524 1.1458 1.3796 1.7519 1.8789 1.7172 1.4286 1.5758 1.7143 1.7576 1.7548 1.8125 2.4994 2.7245 2.8515 2.5455 2.3984 2.1502 1.7778];
B=[ 0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0];
C=linspace(0,23,24);
plot(C,A,C,B)
for r=1:7
D1= [trapz(C,A(r,:));trapz(C,B(r,:))];
D2(r)=(sum(D1));
D3=sum(D2);
end
D1
D1 = 2×1
38.6566 30.0233
D2
D2 = 1×7
65.3881 69.2820 69.8439 70.0448 70.0448 69.9646 68.6799
D3
D3 = 483.2482
As you can see D1

采纳的回答

Sulaymon Eshkabilov
If understood your question correctly, this is what you're trying to compute is the area under the big bell curve?
A=[ 0.6495 0.7393 0.7551 0.7947 0.7974 0.8713 1.0482 1.2621 1.6027 1.7189 1.5710 1.3070 1.4416 1.5684 1.6080 1.6053 1.6581 2.2865 2.4925 2.6087 2.3288 2.1941 1.9671 1.6265;
0.7210 0.8207 0.8383 0.8823 0.8852 0.9673 1.1636 1.4010 1.7792 1.9081 1.7440 1.4509 1.6004 1.7411 1.7850 1.7821 1.8407 2.5383 2.7669 2.8959 2.5852 2.4357 2.1836 1.8055;
0.7314 0.8324 0.8503 0.8949 0.8979 0.9811 1.1803 1.4211 1.8046 1.9354 1.7689 1.4716 1.6233 1.7660 1.8106 1.8076 1.8671 2.5746 2.8065 2.9373 2.6222 2.4706 2.2149 1.8314;
0.7351 0.8366 0.8546 0.8994 0.9024 0.9860 1.1862 1.4283 1.8137 1.9452 1.7779 1.4791 1.6315 1.7749 1.8197 1.8167 1.8765 2.5876 2.8207 2.9522 2.6354 2.4830 2.2261 1.8406;
0.7351 0.8366 0.8546 0.8994 0.9024 0.9860 1.1862 1.4283 1.8137 1.9452 1.7779 1.4791 1.6315 1.7749 1.8197 1.8167 1.8765 2.5876 2.8207 2.9522 2.6354 2.4830 2.2261 1.8406;
0.7336 0.8350 0.8529 0.8976 0.9006 0.9841 1.1839 1.4254 1.8101 1.9413 1.7743 1.4761 1.6282 1.7713 1.8160 1.8131 1.8727 2.5824 2.8150 2.9462 2.6301 2.4781 2.2216 1.8369;
0.7100 0.8081 0.8254 0.8687 0.8716 0.9524 1.1458 1.3796 1.7519 1.8789 1.7172 1.4286 1.5758 1.7143 1.7576 1.7548 1.8125 2.4994 2.7245 2.8515 2.5455 2.3984 2.1502 1.7778];
B=[ 0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0.6104 2.0730 3.0518 4.5145 5.4933 5.4933 4.2725 2.4414 1.4627 0.6104 0 0 0 0 0 0];
C=linspace(0,23,24);
for ii=1:7
D1 = [cumtrapz(C,A(ii,:));cumtrapz(C,B(ii,:))];
D1 = @(La,Lb) max(D1(C<=Lb)) - min(D1(C>=La));
Area = D1(6, 18);
end; sum(Area)
ans = 9.8980
  1 个评论
Pietro Fiondella
Pietro Fiondella 2022-6-22
Thanks for your feedback, it's usefoul but thats not what i'm looking for.
I would like to obtain a row vector in wich i have the areas below each graph as elements.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by