Reputation: 31
Hi everyone, I have four curves in matlab. The two of them are calculated through the following formulas y=x and y=1-x The other two curves are calculated through a number (13) of values. All of them shaped an area with their intersection points (ABCD) that I want to calculate. I have to use trapz and if yes how?
and a second question. How can I fill in with a new color the spesific area (ABCD)?
Thank you in advance
Upvotes: 0
Views: 1775
Reputation: 722
Have you tried integrating the difference of the 2 functions between the certain boundaries given by ur 2 other values?
Area between the functions y1 = x and y2 = 1-x is going to be an integral of 1-2x or 2x-1 which is going to be the same area in absolute value.
Use this if you are integrating between 2 curves and 2 boundaries:
A = integral(function,xmin,xmax);
To interate between four curves y1 y2 x1 x2, use something like a double integral.
Function is the absolute difference between y1 and y2, and xmin/xmax are your function boundaries x1 and x2 depending on how you want them, and ymin/ymax are your boundaries for the y axis.
A = integral2(function,xmin,xmax,ymin,ymax);
Upvotes: 0
Reputation: 978
Are you working in the xy plane?
How about doing [r,c]=find(y1==y2); among every 2 curves?
Upvotes: 0