plot Quadric Surfaces in General Form in matlab

前端 未结 1 1484

I have Quadric Surface equation \"enter

I know A,B,C... How can I plot my equation in

相关标签:
1条回答
  • 2021-01-06 11:22

    Your best bet is to produce a 3D contour plot of your function with a single contour at the function value 0. To do this with reasonable accuracy, compute your function F at a number of points x, y, z as follows:

    gv = linspace(-30,30,50); % adjust for appropriate domain
    [xx yy zz]=meshgrid(gv, gv, gv);
    F = A*xx.*xx + B*yy.*yy + C*zz.*zz+ ... etc
    
    figure
    isosurface(xx, yy, zz, F, 0)
    

    The reason to do it this way is that your function is typically multi-valued- that is, for a given value of X and Y there may be two possible answers for Z. By doing things this way you effectively bypass that problem - instructing matlab to put a surface anywhere that the function is zero.

    Note that I gave an arbitrary vector gv for the grid - that is, the points on which the function is evaluated. To get an accurate and visually pleasing result you probably need around 50 points in each dimension within the range over which a solution is possible (this may be different in the three dimensions);

    For example, with

    F = xx.^2 + 2*yy.^2 + 0.5*zz.^2 + .4*xx.*yy + .5*xx.*zz + .6*yy.*zz + 7*xx + 8*yy + 9*zz - 100;
    

    You get the following figure:

    enter image description here

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