MATLAB: How can i fill the common areas of two curves

areafill

I can draw two cureves as below.
y1 = @(x) 3*x.^2 + 2*x +1;
y2 = @(x) -5*x.^2 + x + 20;
x=-5:0.1:5;
figure(3),plot(x,y1(x),x,y2(x));
Then, now i would like to fill the common areas with red color but i have no idea.
How can i do that?
And what about if i would like to fill the common areas of three different curves?

Best Answer

Another possible solution:
y1 = @(x) 3*x.^2 + 2*x +1;
y2 = @(x) -5*x.^2 + x + 20;
x = -5:0.1:5;
pgon1 = polyshape(x,y1(x));
pgon2 = polyshape(x,y2(x));
figure
plot(x,y1(x),x,y2(x))
hold on
plot(intersect(pgon1,pgon2),'EdgeColor','none')
pgon.png