how can i shade the area between two curve

34 views (last 30 days)
i have two curve that intersect at two points,my aim is to calculate the area between this two curve.this is ok but on the other hand,i'd like to see this two curve in the figure,this is also ok but i don't know how i can shade the area that is between two curve.this is my program:
syms t
y1=t^2;
y2=-(t^2-16);
fg=figure;
ax=axes;
ez1=ezplot(char(y1),[-8,8]);
hold on
ez2=ezplot(char(y2),[-8,8]);
legend('y1= t^2','y2= -(t^2-16)')
set(ez1,'color',[1 0 0])
title(ax,['y1= t^2' ' y2= -(t^2-16)'])
t=solve('-(t^2-16)-t^2=0');
kokler=double(t)
alan=quad('-(t.^2-16)-t.^2',kokler(2),kokler(1))

Accepted Answer

bym
bym on 18 Aug 2011
x = linspace(kokler(1),kokler(2)); % 100 points between intersections
yy1 =x.^2; %lower function
yy2 = -(x.^2-16); % upper function
x = [x,x]; % repeat x values
yy = [yy1,yy2]; % vector of upper & lower boundaries
fill(x,yy,'b') % fill area defined by x & yy in blue
  4 Comments
Nate Roberts
Nate Roberts on 10 Oct 2017
There is a different answer that is more clear. Look here instead: More Clear Answer

Sign in to comment.

More Answers (1)

hanif
hanif on 31 Jan 2015
I have two overlay image that intersect at two points,my aim is to calculate the area between this two curve.I don't know how to shade the area that is between two curve.this is my program:
RGB=imread('DETECTOR1.PNG');
A=imread('DETECTOR2.PNG');
F=imfuse(RGB,A,'blend','Scaling','Joint');
imwrite(RGB,'Detectors.PNG');
imtool(F);

Community Treasure Hunt

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

Start Hunting!