I should write the program to get the positions x,y,z (lattice points) and then repeat these positions(lattice cube) in the x,y,z direction with the constant(lattice constant).my code is just working in one direction(x), how can I fix my code to work in all 3 x,y,z directions?
for k=0:o for j=0:m for i=0:n xpp(8*i+1:8*i+8,1)=xp+D*i; ypp(8*i+1:8*i+8,1)=yp+D*j; zpp(8*i+1:8*i+8,1)=zp+D*k; end endend%start
a=importdata('structure.xyz');xp=a.data(:,1);yp=a.data(:,2);zp=a.data(:,3);n=1;m=1;o=1;xpp=xp;ypp=yp;zpp=zp;for k=0:o for j=0:m for i=0:n xpp(8*i+1:8*i+8,1)=xp+D*i; ypp(8*i+1:8*i+8,1)=yp+D*j; zpp(8*i+1:8*i+8,1)=zp+D*k; end endendfileID = fopen('N.txt','w');fprintf(fileID,'%s\n','silicon');fprintf(fileID,'si %f %f %f\n',[xpp,ypp,zpp].');fclose(fileID);
Best Answer