“…Therefore, you can't % consider the top or bottom row, since you would have only 5 % surrounding points. dist_init=zeros (8,3); dist_def=zeros (8,3); %temporary placeholder, its for the x,y,z distance from a given point to %its 8 neighbors row=mesh_init(n).row; column=mesh_init(n).column; if (column>1)&(column<columns) %calculates the distance between the marker surrounded by 8 neighbors %start at neighbor at the right and go counterclockwise to other %seven neighbors, for more explanation, see Wolfrum thesis dist_init(1,:)=mesh_init(n+1).coord-mesh_init(n).coord; dist_init(2,:)=mesh_init(n+columns+1).coord-mesh_init(n).coord; dist_init(3,:)=mesh_init(n+columns).coord-mesh_init(n).coord; dist_init(4,:)=mesh_init(n+columns-1).coord-mesh_init(n).coord; dist_init(5,:)=mesh_init(n-1).coord-mesh_init(n).coord; dist_init(6,:)=mesh_init(n-columns-1).coord-mesh_init(n).coord; dist_init (7,:)=mesh_init(n-columns).coord-mesh_init(n).coord; dist_init (8,:)=mesh_init(n-columns+1).coord-mesh_init(n).coord; %does same thing for bent leg dist_def(1,:)=mesh_def(n+1).coord-mesh_def(n).coord; dist_def(2,:)=mesh_def(n+columns+1).coord-mesh_def(n).coord; dist_def(3,:)=mesh_def(n+columns).coord-mesh_def(n).coord; dist_def(4,:)=mesh_def(n+columns-1).coord-mesh_def(n).coord; dist_def(5,:)=mesh_def(n-1).coord-mesh_def(n).coord; dist_def(6,:)=mesh_def(n-columns-1).coord-mesh_def(n).coord; dist_def (7,:)=mesh_def(n-columns).coord-mesh_def(n).coord; dist_def (8,:)=mesh_def(n-columns+1).coord-mesh_def(n).coord; end if column==1 %if the point is in the first column, its three neighbours on the %lefthand side are in last column, so the code has to be changed to %reflect this counting method dist_init(1,:)=mesh_init(n+1).coord-mesh_init(n).coord;% here the markers on the righthand side are in first column, so % again some slight changes must be made to get the appropriate % neighbors dist_init(1,:)=mesh_init(n-columns+1).coord-mesh_init(n).coord; dist_init(2,:)=mesh_init(n+1).coord-mesh_init(n).coord; dist_init(3,:)=mesh_init(n+columns).coord-mesh_init(n).coord; dist_init(4,:)=mesh_init(n+columns-1).coord-mesh_init(n).coord; dist_init(5,:)=mesh_init(n-1).coord-mesh_init(n).coord; dist_init(6,:)=mesh_init(n-columns-1).coord-mesh_init(n).coord; dist_init (7,:)=mesh_init(n-columns).coord-mesh_init(n).coord; dist_init (8,:)=mesh_init(n-2*columns+1).coord-mesh_init(n).coord; dist_def(1,:)=mesh_def(n-(columns-1)).coord-mesh_def(n).coord; dist_def(2,:)=mesh_def(n+1).coord-mesh_def(n).coord; dist_def(3,:)=mesh_def(n+columns).coord-mesh_def(n).coord; dist_def(4,:)=mesh_def(n+columns-1).coord-mesh_def(n).coord; dist_def(5,:)=mesh_def(n-1).coord-mesh_def(n).coord; dist_def(6,:)=mesh_def(n-columns-1).coord-mesh_def(n).coord; dist_def (7,:)=mesh_def(n-columns).coord-mesh_def(n).coord; dist_def (8,:)=mesh_def(n-2*columns+1).coord-mesh_def(n).coord; end %calculating eight normal vectors between pairs of neighboring vectors normals=zeros (8,3); %placeholder for i=1:7, %ORIGINAL CODE, but normal vectors in wrong direction (point inwards)!!!!!!!!!!!!!!!!! %normals(i,:)=cross(dist_init(i,:),dist_init(i+1,:))/norm(cross(dist_init(i,:),dist_...…”