Graph limits and area

1 view (last 30 days)
Mughees Asif
Mughees Asif on 6 Mar 2019
Commented: KSSV on 6 Mar 2019
I have the following code:
x = linspace(-5, 5, 1000);
y1 = -x;
y2 = x.^2-4;
lidx = y1 >= y2;
figure
set(findobj(gcf,'type','axes'),'FontName','Arial','FontSize',12,'FontWeight','Bold', 'LineWidth', 2);
plot(x, y1, 'k')
hold on
plot(x, y2, 'k')
patch([x(lidx) fliplr(x(lidx))], [y1(lidx), fliplr(y2(lidx))], 'b', 'FaceAlpha', 0.4)
hold off
xlim([-5 5])
ylim([-5 5])
box on
grid on
axis=gca;
axis.XAxisLocation = 'origin';
axis.YAxisLocation = 'origin';
title('Graph of the integration domain')
xlabel('x')
ylabel('y')
which gives the following graph. Is there a way of putting dashed lines where the green line is to show limits and to reduce the blue patch within the area. Thank you.
graph_Mathworks.png
  1 Comment
KSSV
KSSV on 6 Mar 2019
Get those intersection points and use patch.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!