Shade area under two lines

x1 and x2 are restricted to positive values only. Need to shade the area under two intersecting lines. Only want the area that is included under the intersection of both lines. x1 + 2*x2=4 and 3*x1 + 2*x2=6

回答 (2 件)

KSSV
KSSV 2022 年 3 月 29 日

0 投票

x = linspace(0,5) ;
y1 = (4-x)/2 ;
y2 = (6-3*x)/2 ;
x = [x flip(x)] ;
y = [y1 flip(y2)] ;
patch(x,y,'r')

2 件のコメント

Jeffrey Meisner
Jeffrey Meisner 2022 年 3 月 29 日
Looking for the area below where both lines intersect
Image Analyst
Image Analyst 2022 年 3 月 29 日
Just take the min
bottomLine = min([y1; y2]); % Assuming y1 and y2 are row vectors.
area = sum(bottomLine);
Or you can use trapz() depending on what method you want to use for finding the sum of areas under the bottomLine elements.

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

カテゴリ

質問済み:

2022 年 3 月 29 日

コメント済み:

2022 年 3 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by