# How to plot two curves on same axis system ?

224 views (last 30 days)
Rishabh Pratap Singh on 2 Jul 2017
I wanted to know that if i have a curve y^2 = 8*x and other curve x^2 = 8*y on same graph.. how can i plot it? Also how would i shade the bounded region?

John BG on 2 Jul 2017
Hi Rishabh
1.
Plotting curves, here it's considered you only intend to work with real values:
clear all;close all
x=[-10:.1:10];
y11=(8*x).^.5;y12=-(8*x).^.5;y2=1/8*x.^2;
plot(x,y11,'b-')
% h1=gca
% yyaxis(h1,'left')
hold all
% hold(h1,'on')
plot(x,y12,'b-')
% yyaxis(h1,'left')
plot(x,y2,'r-')
% h2=gca
% yyaxis(h2,'right')
grid on
.
2.
Solving the intersection point, for instance with
f1=@(x1) 1/8*x1.^2-(8*x1)^.5
x0=fzero(f1,6)
x0 =
8
3.
Getting the reference vector for only the bounded area
nx2=find(x==x0)
nx1=find(x==0)
nx=[nx1:1:nx2]
4.
hold all
patch([x(nx) fliplr(x(nx))], [y2(nx) fliplr(y11(nx))], [0.7 0.7 0.7])
.
.
Let me know if you would be interested to have an answer for the Complex domain.
John BG
Rishabh Pratap Singh on 2 Jul 2017
Thanks john, it totally worked!