MATLAB: Help needed to find location of atoms and visualize them

atomMATLAB

I need to create a matlab script that will output location of silicon atoms in x,y,z coordinates in a simple cubic lattice with lattice constant a. Consider the silicon atom is located in (a/2,a/2,a/2) at each cell. Next step will be to plot the atoms. Input will be number of cells. Any idea how to do that?

Best Answer

Try meshgrid():
a = 5; % Whatever
x = a/2 : a : 15;
[X, Y, Z] = meshgrid(x, x, x)
x = X(:);
y = Y(:);
z = Z(:);
for k = 1 : length(x)
fprintf('(x, y, z) = (%.1f, %.1f, %.1f)\n', ...
x(k), y(k), z(k));
end
Use inputdlg() to get the user input.