function n=showbeadscolorcoded(list,colorcode,scalaminus,scalaplus,beadsize,xmin,xmax,cut) % % % This function displays the particles color coded according to the list of values given in "colorcode" % (which is, for example, a component of the strain tensor). % list is an N by 3 list of the x,y,z coordinates of the particles, % colorcode an N by 1 list of values, % scalaminus and scalaplus the minimum and maximum values of particles to be shown, % beadsize the size of the particles in the plot, % xmin and xmax the lower and upper limit of the section to be displayed, % and cut(=1,2, or 3) the direction (x,y or z) perpendicular to the cut. % % Peter Schall and Dan Bonner % % [n,m] = size(list); [a,b,c] = sphere(12); colormatrix=ones(13); a=beadsize/2*a; b=beadsize/2*b; c=beadsize/2*c; % Set the scale i=1; while colorcode(i) ==1000 i=i+1; end surf(a+list(i,1),b+list(i,2),c+list(i,3),scalaplus*colormatrix,'edgecolor','none'); hold on; surf(a+list(i,1),b+list(i,2),c+list(i,3),scalaminus*colormatrix,'edgecolor','none'); % Start drawing the strain field particles for i=1:n if list(i,cut) > xmin & list(i,cut) < xmax if colorcode(i) == 1000 | colorcode(i) < scalaminus | colorcode(i) > scalaplus scatter3(list(i,1),list(i,2),list(i,3),'ko'); else surf(a+list(i,1),b+list(i,2),c+list(i,3),colorcode(i)*colormatrix,'edgecolor','none'); end hold on; end end hold off; if cut == 1 view(90,0); elseif cut == 2 view(0,0); elseif cut == 3 view(34,30); end camlight left; lighting phong; xlabel('x','FontSize',22); ylabel('y','FontSize',22), zlabel('z','FontSize',22); axis equal; axis([0,8,0,8,0,7]); %zoom(1.2); set(gca,'FontSize',15); h=colorbar('vert'); set(h,'FontSize',15);