1

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.

4

2 回答 2

4

I believe ezsurf comes close to what you want. You would first have to solve each equation for z, then make a function for that equation and plot it with ezsurf. Here's how to do it with your first equation from above:

func1 = @(x, y) sqrt(1-x.^2-y.^2);
ezsurf(func1);

This should display the upper half of a sphere.

To display all three equations together, you can do the following:

func1 = @(x, y) sqrt(1-x.^2-y.^2);
func2 = @(x, y) 0.5.*x.^2+0.25.*y.^2;
func3 = @(x, y) sqrt(4.*y-3.*x.^2);
ezsurf(func1, [-1 1 -1 1]);
hold on;
ezsurf(func2, [-1 1 -1 1]);
ezsurf(func3, [-1 1 -1 1]);
axis([-1 1 -1 1 0 1]);

and the resulting plot will look like this:

enter image description here

By rotating the plot, you will notice that there appear to be two points where all three surfaces intersect, giving you two solutions for the system of equations.

于 2009-05-29T14:36:28.587 回答
0

"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.

于 2009-05-29T13:25:46.653 回答