global xl yl
clear all
clc;
nc=4;
ms=[1 , 10, 0 , 0 , 10 , 0 , 0 ;
1 , 10, 10 , 0 , 10 , 10 , 0 ;
1 , 10, 10 , 10 , 0 , 10 , 0 ;
1 , 10, 0 , 10 , 0 , 0 , 0];
nb=0;
for i=1:nc
if ms(i,1) == 1
x1=ms(i,3);
y1=ms(i,4);
x2=ms(i,5);
y2=ms(i,6);
ne=ms(i,2);
[xl1,yl1]=rectline(x1,y1,x2,y2,ne);
for j=1:ne
nb=nb+1;
xl(nb)=xl1(j);
yl(nb)=yl1(j);
end
end
end
plot(xl,yl,'m*')
function [xl,yl]=rectline(xj,yj,xk,yk,ne)
%
%Function RECTLINE evaluates:
% The coordinates of the end points of the constant
% elements on straight line segment using its end coordinates
% xl : x coordinate of the end points of the boundary elements
% yl : y coordinate of the end points of the boundary elements
dx=xk-xj;
dy=yk-yj;
xl=zeros(ne,1);
yl=zeros(ne,1);
for j=1:ne
xl(j)=xj+(j-1)*dx/ne;
yl(j)=yj+(j-1)*dy/ne;
end