MATLAB 中的光学晶格

Optical Lattice in MATLAB

我正在编写脚本来绘制以下图片

下面的代码工作正常并绘制出与上面相同的形状,没有球体。

clear all
PS=zeros(100,100); 
A=2.4; 
B=3.4; 

for i=1:100 

  for j=1:100        
   PS(i,j) = cos((.1*i)*A)*cos((.1*j)*B); 
  end 
end 
surfc(PS)

我的问题是,如何绘制这些球体?

绘制 atoms/spheres 可以很容易地完成,一旦你在你的格子上有了它们的坐标,那就是你需要找到(如维基百科文章中所述)潜在的最小值。我假设你可以弄清楚那部分。如果不是我误解了你的问题抱歉!

对于演示,我将使用较小的网格以减少原子数量,并使用 scatter3 绘制球体。然后你可以用精确的最小值替换我的近似值。

完整代码如下:

clear
clc
close all

N = 30;
PS=zeros(N,N); 
A=2.4; 
B=3.4; 

for i=1:N

    for j=1:N 

        PS(i,j) = cos((.1*i)*A)*cos((.1*j)*B); 
    end

end

%// Approximate locations of the atoms. You can calculate this more
%// accurately of course.
xAtom = [1 10 10 19 28 28];
yAtom = [13 2 27 13 2 27];

%// Plot atoms at height of .6.
zAtom = repmat(.6,1,numel(xAtom));

surfc(PS)

hold on

%// Scatter plot. You can customize the parameters.
scatter3(xAtom,yAtom,zAtom,200,'k','filled')

rotate3d on

并且输出: