how can i shade the area between two curve

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))

2 Kommentare

Jan
Jan am 18 Aug. 2011
Which are the two curves in your code?
murat artan
murat artan am 19 Aug. 2011
y1 and y2

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

bym
bym am 18 Aug. 2011

1 Stimme

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 Kommentare

murat artan
murat artan am 19 Aug. 2011
this is ok, but what did you do here? I don't understand much.
thank you very much
bym
bym am 19 Aug. 2011
I have commented the code
murat artan
murat artan am 20 Aug. 2011
thanks a lot
Nate Roberts
Nate Roberts am 10 Okt. 2017
There is a different answer that is more clear. Look here instead: More Clear Answer

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 18 Aug. 2011

Kommentiert:

am 10 Okt. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by