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

前端 未结 2 1876
花落未央
花落未央 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.

    0 讨论(0)
  • 2021-01-25 13:46

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

    0 讨论(0)
提交回复
热议问题