%% Code that i used to creat that figure. %% I am trying to connect the dots to all nearby dots. %% To make 9 node element like as shown below. there will be Nx*Ny elements of this type.
clc ; clear;% Dimensions of the plate
L = 1 ; % Length of the Plate along X-axes
B = 1 ; % Breadth of the Plate along Y-axes
% Number of Elements required
Nx = 3 ; % Number of Elements along X-axes
Ny = 3 ; % Number of Elements along Y-axes
%----------------------------------------
nel = Nx*Ny ; % Total Number of Elements in the Mesh
nnel = 9 ; % Number of nodes per Element
% Number of points on the Length and Breadth
npx = 2*Nx+1 ;npy = 2*Ny+1 ;nnode = npx*npy ; nx = linspace(0,L,npx) ;ny = linspace(0,B,npy) ;[xx yy] = meshgrid(nx,ny) ;% To get the Nodal Connectivity Matrix
coordinates = [xx(:) yy(:)] ;NodeNo = 1:nnode ;nodes = zeros(nel,nnel) ; NodeNo = reshape(NodeNo,npx,npy); %
nodes(:,1) = reshape(NodeNo(1:2:npx-2,1:2:npy-2),nel,1); nodes(:,2) = reshape(NodeNo(3:2:npx,1:2:npy-2),nel,1); nodes(:,3) = reshape(NodeNo(3:2:npx,3:2:npy),nel,1); nodes(:,4) = reshape(NodeNo(1:2:npx-2,3:2:npy),nel,1); nodes(:,5) = reshape(NodeNo(2:2:npx-1,1:2:npy-2),nel,1); nodes(:,6) = reshape(NodeNo(3:2:npx,2:2:npy-1),nel,1); nodes(:,7) = reshape(NodeNo(2:2:npx-1,3:2:npy),nel,1); nodes(:,8) = reshape(NodeNo(1:2:npx-2,2:2:npy-1),nel,1); nodes(:,9) = reshape(NodeNo(2:2:npx-1,2:2:npy-1),nel,1); %%
X = zeros(nnel,nel) ;Y = zeros(nnel,nel) ; for iel = 1:nel Y(:,iel) = coordinates(nodes(iel,:),1) ; X(:,iel) = coordinates(nodes(iel,:),2) ; end x1 = X(1,:); x2 = X(2,:); x3 = X(3,:); x4 = X(4,:); x5 = X(5,:); x6 = X(6,:); x7 = X(7,:); x8 = X(8,:); x9 = X(9,:); y1 = Y(1,:); y2 = Y(2,:); y3 = Y(3,:); y4 = Y(4,:); y5 = Y(5,:); y6 = Y(6,:); y7 = Y(7,:); y8 = Y(8,:); y9 = Y(9,:); %% figureplot(x1,y1,'b.','MarkerSize',10)xlim([-0.2 1.2])ylim([-0.2 1.2]) hold onplot(x2,y2,'b.','MarkerSize',10)plot(x3,y3,'b.','MarkerSize',10)plot(x4,y4,'b.','MarkerSize',10)plot(x5,y5,'b.','MarkerSize',10)plot(x6,y6,'b.','MarkerSize',10)plot(x7,y7,'b.','MarkerSize',10)plot(x8,y8,'b.','MarkerSize',10)plot(x9,y9,'b*','MarkerSize',10)hold off
Best Answer