【问题标题】:isosurface function MATLAB usage等值面函数MATLAB使用
【发布时间】:2011-12-02 15:15:26
【问题描述】:

您好,谁能给我一个简单的例子,说明如何在 MATLAB 中使用等值面函数。 如果您键入help isosurface,给出的示例非常令人困惑。在谷歌上搜索并没有帮助,因为没有人在任何地方给出简单的例子。他们都使用预定义的功能,如 flow

对于初学者,假设我有点 (x,y,z) 其中 z=0 并且在每个点我定义一个常数 函数f(x,y,z)=6。因此,如果我在等值 6 上使用等值面函数,我希望 MATLAB 给我一个 3d 图,其中 XY 平面以某种颜色突出显示,比如绿色。

【问题讨论】:

    标签: matlab 3d plot


    【解决方案1】:

    我不太明白你的例子,但这里是你如何使用isosurface 来绘制一个球体:

    %# create coordinates
    [xx,yy,zz] = meshgrid(-15:15,-15:15,-15:15);
    %# calculate distance from center of the cube
    rr = sqrt(xx.^2 + yy.^2 + zz.^2);
    
    %# create the isosurface by thresholding at a iso-value of 10
    isosurface(xx,yy,zz,rr,10);
    
    %# make sure it will look like a sphere
    axis equal 
    

    【讨论】:

      【解决方案2】:

      你举的例子很无趣,甚至可能有问题。

      通过将所有点折叠到z=0,,您不再可以/不需要使用ISOSURFACE,而应该调用CONTOUR。即使这样,常量函数f(X,Y)=6 也不会显示任何内容...

      由于@Jonas 已经展示了如何使用 ISOSURFACE,以下是 CONTOUR 函数的示例:

      %# create a function to apply to all X/Y coordinates
      [X,Y] = meshgrid(-2:0.1:2,-1:0.1:1);
      f = @(X,Y) X.^3 -2*Y.^2 -3*X;
      
      %# plot the function surface
      subplot(121), surfc(X,Y,f(X,Y))
      axis equal, daspect([1 1 3])
      
      %# plot the iso-contour corresponding to where f=-1
      subplot(122), contour(X,Y,f(X,Y),[-1 -1]), 
      axis square, title('Contour where f(X,Y)=-1')
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-10-23
        • 2021-11-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多