How to plot a nonlinear system of 3 equations with 3 symbolic variables in MATLAB?

前端 未结 2 1875
花落未央
花落未央 2021-01-25 13:05

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;
         


        
2条回答
  •  孤街浪徒
    2021-01-25 13:43

    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:

    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.

提交回复
热议问题