area between two overlapping plots
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sahithya S Iyer
am 17 Okt. 2017
Kommentiert: Alexander Collins
am 9 Apr. 2021
Hi,
I have a plot that of two curves that overlap and want to calculate the area of overlap. The plot looks as below. The curves are from data set and are not fit to any equation. How you I calculate the area of the overlapping region ?
Thanks in advance.

0 Kommentare
Akzeptierte Antwort
KL
am 17 Okt. 2017
You could use trapz to calculate the area under the curve.
But before that you need to calculate the intersecting portion of the curves. Check this example with some dummy data,
x1 = 0.01:0.01:1;
y1 = [sin(pi*x1) zeros(1,20)];
x2 = x1+0.2;
y2 = [zeros(1,20) sin(pi*x1)];
y_d = [y2(y2<y1) y1(y1<y2)];
area_int = trapz(y_d)
%plots in case you want to visualize
plot(y1)
hold on
plot(y2)
plot(y_d,'k-o')
2 Kommentare
Alexander Collins
am 9 Apr. 2021
I noticed that for when I do this the overlap values very close to zero (where one curve is on the order of 10E-7) get reshuffled to the end of the array, causing the whole thing to get shifted out of alignment.
Is this a known thing? Any ideas?

Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!