等值面函数 MATLAB 用法

发布于 2024-12-08 14:05:14 字数 329 浏览 0 评论 0原文

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

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

Hi can any one give me a simple example of how to use the isosurface function in MATLAB.
The example given if you type help isosurface is quite confusing. Searching on google did not help as no one gives simple examples anywhere. All of them use predefined functions like
flow.

For starters, suppose i have points (x,y,z) where z=0 and at each point I define a constant
function f(x,y,z)=6. So if I use the isosurface function on the isovalue 6 I would like MATLAB to give me a 3d plot with the XY plane highlighted in some colour, say green.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻找我们的幸福 2024-12-15 14:05:14

我不太明白你的例子,但以下是如何使用 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 

I don't quite understand your example, but here's how you use isosurface to draw a sphere:

%# 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 

enter image description here

千仐 2024-12-15 14:05:14

你给出的例子非常无趣,事实上甚至可能是有问题的。

通过将所有点折叠为 z=0,您不再可以/不需要使用 ISOSURFACECONTOUR 应该被调用。即使如此,常量函数 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')

在此处输入图像描述

The example you gave is very uninteresting, in fact maybe even problematic.

By collapsing all points to z=0, you no longer can/need to use ISOSURFACE, and CONTOUR should be called instead. Even then, a constant function f(X,Y)=6 won't show anything either...

Since @Jonas already showed how to use ISOSURFACE, here is an example for the CONTOUR function:

%# 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')

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文