Computing the overlapping area of curves

3 ビュー (過去 30 日間)
Deepa Maheshvare
Deepa Maheshvare 2022 年 7 月 3 日
編集済み: Chunru 2022 年 7 月 4 日
I have a set of datapoints corresponding to 5 curves.
scale = 1.5;
x1 = [0,4,6,10,15,20]*scale;
y1 = [18,17.5,13,12,8,10];
x2 = [0,10.5,28]*scale;
y2= [18.2,10.6,10.3];
x3 = [0,4,6,10,15,20]*scale;
y3 = [18,13,15,12,11,9.6];
x4 = [9,17,28]*scale;
y4 = [5,5.5,7];
x5 = [1,10,20]*scale;
y5 = [3,0.8,2];
plot(x1,y1, '*-', x2, y2, '*-', x3, y3, '*-', x4, y4, '*-', x5, y5, '*-')
I want to find the overlapping area under these curves.
Suggestions on the functions that could be uded to find the intersecting area and the x limits of the intersecting area will be really helpful.
  3 件のコメント
Chunru
Chunru 2022 年 7 月 4 日
Which curves do you mean? How the overlapping area is defined?
Deepa Maheshvare
Deepa Maheshvare 2022 年 7 月 4 日
Thank you for the reply. I am interested in finding the area under each of the curve and visualize the area that overlaps.

サインインしてコメントする。

採用された回答

Chunru
Chunru 2022 年 7 月 4 日
編集済み: Chunru 2022 年 7 月 4 日
scale = 1.5;
x{1} = [0,4,6,10,15,20]*scale;
y{1} = [18,17.5,13,12,8,10];
x{2} = [0,10.5,28]*scale;
y{2}= [18.2,10.6,10.3];
x{3} = [0,4,6,10,15,20]*scale;
y{3} = [18,13,15,12,11,9.6];
x{4} = [9,17,28]*scale;
y{4} = [5,5.5,7];
x{5} = [1,10,20]*scale;
y{5} = [3,0.8,2];
figure; hold on
xmin = -inf; xmax=inf;
for i=1:length(x)
area(x{i}, y{i}, 'FaceAlpha', 0.5); % visualize area with transparancy
a(i) = trapz(x{i}, y{i}); % compute area
xmin = max(xmin, min(x{i}));
xmax = min(xmax, max(x{i}));
end
xline([xmin xmax], 'LineWidth', 2)
legend
a
a = 1×5
369.7500 501.1125 379.5000 166.1250 46.6500
  2 件のコメント
Deepa Maheshvare
Deepa Maheshvare 2022 年 7 月 4 日
Thanks so much. Could we find/highlight the area that is intersected by all curves?
Chunru
Chunru 2022 年 7 月 4 日
See the update.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCurve Fitting Toolbox についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by