Plotting Implicit Algebraic equations in MATLAB

前端 未结 4 895
天命终不由人
天命终不由人 2020-12-01 05:43

I wish to plot implicit functions in MATLAB. Like x^3 + xy + y^2 = 36 , equations which cannot be made into simple parametric form. Is there any simple method ?

4条回答
  •  余生分开走
    2020-12-01 06:26

    In case you want to plot an implicit surface, for example a Horned cube, you can do something like the following.

    The idea is to calculate all values of the function (even if they don't equal to zero) and then create an isosurface that will define your equality. In this example the implicit function equals to zero.

    fun=@(x,y,z)(1-x.^8-3.*y.^8-2.*z.^8+5.*x.^4.*z.^2.*y.^2+3.*y.^4.*x.^2.*z.^2) ;
    
    [X,Y,Z]=meshgrid(-2:0.1:2,-2:0.1:2,-2:0.1:2);
    
    val=fun(X,Y,Z);
    
    fv=isosurface(X,Y,Z,val,0);
    
    p = patch(fv);
    isonormals(X,Y,Z,val,p)
    set(p,'FaceColor' , 'red');
    set(p,'EdgeColor' , 'none');
    daspect([1,1,1])
    view(3); axis tight
    camlight 
    lighting phong
    axis off
    

    enter image description here

    Additionally there is a Matlab File Exchange submission called ezimplot3D that seems to do the job also, as @knedlsepp suggests.

提交回复
热议问题