views:

968

answers:

3

I don't have a lot of experience with Matlab. I know that you can plot equations with 2 variables like this:

ezplot(f1)
hold on
ezplot(f2)
hold off;

How would you plot three equations with three symbolic variables?

An example system would be:

x^2+y^2+z^2-1=0
2*x^2+y^2-4*z=0
3*x^2-4y+z^2=0

It would be ideal if there was a way to plot any system of 3 equations.

A: 

"hold on" just says to not erase existing lines & markers on the current axis. you should just be able to do

ezplot(f1);
hold on;
ezplot(f2);
ezplot(f3);
hold off;

I've never used ezplot so can't help you with that one.

Jason S
Unfortunately ezplot can work only with functions of no more than two symbolic variables. What I am looking for is a way to plot a function of 3 variables. It doesn't need to be ezplot.
nagnatron
Oops, I caught the "3 equations" but missed the "3 variables" part.
Jason S
+3  A: 
gnovice
Thanks. This is very helpful and I'm accepting your answer.I know I can use solve(f1,z) for example to solve it for z. But how would I pass the returned function to ezsurf?I triedf = x^2+y^2+z^2-1;f = solve(f, z);func1 = @(x,y) f;ezsurf(func1);That obviously doesn't work but I'm asking is there a way to do it?
nagnatron
The correct syntax for the way you want to do it would be the following: f = 'x^2+y^2+z^2-1'; f2 = solve(f,'z'); ezsurf(f2(1)); hold on; ezsurf(f2(2)); axis equal; This will plot both the top and the bottom of the sphere, unfortunately with a jagged discontinuity between the surfaces at the "equator". To get around the discontinuity, you would have to use SURF instead of EZSURF and define for yourself the x and y points at which the surface will be rendered.
gnovice
Thank you very much for your help!
nagnatron
A: 

What if there is no z at the third equation?

x^2+y^2+z^2-1=0 2*x^2+y^2-4*z=0 3*x^2-4y+...=0 (I removed Z but let assume it is still in 3 dimensional space)

How should be the 3rd function?

?? func3 = @(x,y) sqrt(4.*y-3.*x.^2);

hilaras

related questions