Effacer les filtres
Effacer les filtres

How to plot two curves on same axis system ?

208 vues (au cours des 30 derniers jours)
Rishabh Pratap Singh
Rishabh Pratap Singh le 2 Juil 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?

Réponse acceptée

John BG
John BG le 2 Juil 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.
Shadowing the bounded area
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.
Rishabh, if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
  1 commentaire
Rishabh Pratap Singh
Rishabh Pratap Singh le 2 Juil 2017
Thanks john, it totally worked!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by