Matlab中的特殊功能 [英] Special functions in Matlab
本文介绍了Matlab中的特殊功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取如下图片:
I'm trying to get a picture like the following:
http://upload.wikimedia.org/wikipedia/en/e/e6/Airy-3d.svg
我在做什么错了?
[x,y]=meshgrid(-1:.1:1,-1:.1:1);
surf(x,y,(2*besselj(1,2*pi*sqrt(x.^2+ y.^2)/sqrt(x.^2+ y.^2)).^2)
也...有点旁注,但是如果我在这里使用ndgrid而不是meshgrid,则我的x和y会正确切换?
Also... kind of a side note, but if I used ndgrid instead of meshgrid here my x's and y's would switch right?
推荐答案
以下是我认为方程式有误的几件事:
Here are a couple of things I see wrong with the equation:
- 您的方程式中某处缺少缺失的右括号,也许在第一个
sqrt(x.^2+y.^2)
之后吗?在等式中,看来您是在单独分隔sqrt(x.^2+y.^2)
,这可能不是您想要执行的操作,这就是为什么我认为您从那里缺少括号的原因. - 您可能希望使用
./
而不是使用/
进行矩阵右除(请参见
- There is a missing close parentheses somewhere in your equation, perhaps after the first
sqrt(x.^2+y.^2)
? In the equation, it appears that you are dividingsqrt(x.^2+y.^2)
by itself, which is probably not what you want to do and is why I was thinking you were missing a parentheses from around there. - You will probably want to perform element-wise division using
./
instead of matrix right division using/
(see this link for more detail).
此外,您将需要更改将表面对象的'FaceColor'
属性设置为'none'
,以便仅显示网格的边缘:
In addition, you will want to change the 'FaceColor'
property of the surface object to 'none'
so that only the edges of the mesh are displayed:
[x,y] = meshgrid(-1:.1:1,-1:.1:1);
z = ... %# Compute your z in some way
surf(x,y,z,'FaceColor','none');
这篇关于Matlab中的特殊功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文