How can I execute the level enclosed between the two required functions in the plot?

 Accepted Answer

x = linspace(-1,2) ;
f1 = @(x) (x.^2-2*x+2) ;
f2 = @(x) -x.^2+6 ;
y1 = f1(x) ;
y2 = f2(x) ;
plot(x,y1,x,y2)

2 Comments

Thank you very much for drawing this diagram, can you tell me how to color between these two diagrams with the plot command?
x = linspace(-1,2) ;
f1 = @(x) (x.^2-2*x+2) ;
f2 = @(x) -x.^2+6 ;
y1 = f1(x) ;
y2 = f2(x) ;
x = [x flip(x)] ;
y = [y1 flip(y2)] ;
patch(x,y,'r')

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!