开发者

Graphing special functions in Matlab (2D Bessel)

I'm trying to essentially get something like this where I can see clear ripples at the base but otherwise it's like a Gaussian:

Graphing special functions in Matlab (2D Bessel)

This is kind of unsatisfactory because the ripples aren't very noticeable, it has a very gritty quality that obscures the image a bit, and if you move the graph so that it's just in 2D (so it开发者_开发百科 looks like a circle) I'm not even sure if it's quite like how it should be (the concentric circles seem to be more evenly spaced in the real thing). So, is there a better way to do this?

a = 2*pi;
[X Y] = meshgrid(-1:0.01:1,-1:0.01:1);
R = sqrt(X.^2+Y.^2);
f = (2*besselj(1,a*R(:))./R(:)).^2;
mesh(X,Y,reshape(f,size(X)));
axis vis3d;


You need to change the colormap, or change the surface properties and show shape with reflections. Have a look at the documentation to see all you can do. For example:

a = 2*pi;
[X Y] = meshgrid(-1:0.01:1,-1:0.01:1);
R = sqrt(X.^2+Y.^2);
f = (2*besselj(1,a*R(:))./R(:)).^2;
h=mesh(X,Y,reshape(f,size(X)));
axis vis3d;
%# change from mesh to solid surface with no lines
set(h,'FaceColor','interp','edgeColor','none','facelighting','phong');
%# set reflectance
material shiny
%# add light. Change the position to see different reflections
light('Position',[10 0 10],'Style','local');


Is this what you want?

Surf

Graphing special functions in Matlab (2D Bessel)

Code

a = 2*pi;
[X Y] = meshgrid(-1:0.1:1,-1:0.1:1);
R = sqrt(X.^2+Y.^2);
f = (2*besselj(1,a*R(:))./R(:)).^2;
h=surf(X,Y,reshape(f,size(X)));
axis vis3d;
set(h,'FaceAlpha',0)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜