How to use ezplot in MATLAB?

后端 未结 1 1316
余生分开走
余生分开走 2020-12-10 20:13

I want to use ezplot in MATLAB, and because the function I want to plot consists of a large number of terms I may split it into smaller functions. Let me give a

相关标签:
1条回答
  • 2020-12-10 21:05

    Your error is caused by trying to replace x+1 with y1. ezplot requires that symbolic expressions are functions of only 2 symbolic variables. However, there are 3 symbolic variables (x, y, and y1) in your call to ezplot:

    ezplot('y^2+x*y+x*y^3+y1');
    

    If you use your original equation, everything should work fine:

    ezplot('y^2+x*y+x*y^3+x+1');
    


    EDIT: In case you were curious...

    If you want to plot an equation with 3 variables, you will first need to solve the equation for one of them and then use the function ezsurf (this is illustrated in this answer I gave to another SO question). Technically, y1 is a dependent variable the way you have defined it (since it depends on the variable x). However, for the sake of the following example, let's assume it's an independent variable. The equation:

    y^2 + x*y + x*y^3 + y1 = 0
    

    would be solved for y1 to get the following:

    y1 = -y^2 - x*y - x*y^3
    

    and y1 would be plotted in the following way:

    ezsurf('-y^2-x*y-x*y^3');
    

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