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 Commenti

Which are the two curves in your code?
y1 and y2

Accedi per commentare.

 Risposta accettata

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 Commenti

this is ok, but what did you do here? I don't understand much.
thank you very much
I have commented the code
thanks a lot
There is a different answer that is more clear. Look here instead: More Clear Answer

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by