0

I am writing the script to plot the following pic

enter image description here

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?

John Paul
  • 12,196
  • 6
  • 55
  • 75
Adrian
  • 13
  • 1
  • So @Adrian did you try my suggestion? – Benoit_11 Apr 28 '15 at 12:36
  • Thanks Benoit. It works fine. just need to change .6 to 0.2 or less , in order to change the height for the atmos/spheres. I really appreciate your help. – Adrian May 01 '15 at 18:23
  • Good! If it works could you please mark the answer as 'accepted'? You can click the green checkmark beside it. Thanks! – Benoit_11 May 01 '15 at 18:25

1 Answers1

0

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:

enter image description here

Benoit_11
  • 13,905
  • 2
  • 24
  • 35