I am writing the script to plot the following pic

The following code works fine and plot the same shape as above, without spheres.

```
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)
```

My question is, How to plot these spheres?

# Best How To :

Plotting the atoms/spheres can be done quite easily once you have their coordinates on your lattice, that is you need to find (as mentioned in the Wikipedia article) the potential minima. I assume you can have that part figured out. If not I misunderstood your question sorry!

For the demo I'll use a smaller grid so fewer atoms and use `scatter3`

to draw the spheres. Then you can replace my approximate values with the exact minima.

Here is the whole code:

```
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
```

And the output: