Reputation: 341
I'm trying to plot these 3 functions:
z=y-1;
(x^2)+(y^2)=2x;
(x^2)+(y^2)=4;
As you can see the first one is an implicit function, specifically a line. The other 2 are two explicit functions, specifically circumferences. I need to plot them in the same 3D graph with axis x,y,z to study them. I just need the ranges of the 3 axis to be from 0 to 2. I tried using meshgrid
and mesh
but it seems it's only working for the first function.
Upvotes: 0
Views: 855
Reputation: 89
If you don't mind redefining your functions a bit, you can do it like this with some math:
%function 1
y1=linspace(0,2,1000);
z1=y1-1;
x1=zeros(1,length(y1));
%function 2
theta2=linspace(-pi/2,pi/2,1000);
x2=2*(cos(theta2)).^2;
y2=sqrt(2*x2).*sin(theta2);
z2=zeros(1,length(x2));
%function 3
theta3=linspace(0,2*pi,1000);
x3=2*(cos(theta3));
y3=2*sin(theta3);
z3=zeros(1,length(x2));
%plot
plot3([x1' x2' x3'],[y1' y2' y3'],[z1' z2' z3']);
axis equal;
xlim([0 2]);
ylim([0 2]);
zlim([0 2]);
Upvotes: 1
Reputation: 36710
If available use ezplot
from the symbolic toolbox:
syms x y
ezplot((x^2)+(y^2)==2*x)
Otherwise use the identical named function in a standard MATLAB installation
ezplot('(x^2)+(y^2)=2*x')
Upvotes: 1