How to wirte algorithm for meshing line element?

1 view (last 30 days)
Hi,
As you see in the figure, there is a truss structure composed of 2 elements and 3 nodes. In my code, ın order to calculate the stifness and mass matrices, X,Y and Z coordinate table(Table1) and elements table(Table 2) which is made manually are needed. The code runs with these initial information. Now, i want to divide these two elements into more elements whose number depends on the user.
My question is about the algoritm that will create Table1 and Table 2 automatically. What do you think about it? Is ıt possbible? If yes, would you write the steps for algorithm. I just need ideas.
truss2.JPG

Accepted Answer

hamit Kenan
hamit Kenan on 20 Apr 2019
ı solved it :)
Anyone who needs the same algorithm can send message to me.
  2 Comments
Angkur Shaikeea
Angkur Shaikeea on 9 Mar 2021
Can you share your method please? is it vectorised?
hamit Kenan
hamit Kenan on 9 Mar 2021
Edited: hamit Kenan on 9 Mar 2021
lambda=10; % Ibput Element Number
%%
es=size(H); % H is the Table 2 (ın my code it includes 13 column)
for i=1:es(1)
XX=linspace(B(H(i,2),1),B(H(i,3),1),lambda+1);
YY=linspace(B(H(i,2),2),B(H(i,3),2),lambda+1);
ZZ=linspace(B(H(i,2),3),B(H(i,3),3),lambda+1);
for j=1:(lambda)
h=size(B); %B is the Table 1
if j==lambda
else
B(h(1)+1,1)=XX(j+1)';
B(h(1)+1,2)=YY(j+1)';
B(h(1)+1,3)=ZZ(j+1)';
end
en1=H(i,2);
en2=H(i,3);
hh=size(H);
H(hh(1)+1,1)=hh(1)+1;
H(hh(1)+1,4)=H(i,4);
H(hh(1)+1,5)=H(i,5);
H(hh(1)+1,6)=H(i,6);
H(hh(1)+1,7)=H(i,7);
H(hh(1)+1,8)=H(i,8);
H(hh(1)+1,9)=H(i,9);
H(hh(1)+1,10)=H(i,10);
H(hh(1)+1,11)=H(i,11);
H(hh(1)+1,12)=H(i,12);
H(hh(1)+1,13)=H(i,13);
if j==1
MH=max(H);
MHH=[MH(2) MH(3)];
H(hh(1)+1,2)=en1;
H(hh(1)+1,3)=max(MHH)+1;
elseif j==lambda
bb=size(B);
H(hh(1)+1,3)=en2;
H(hh(1)+1,2)=bb(1);
else
bb=size(B);
H(hh(1)+1,2)=bb(1)-1;
H(hh(1)+1,3)=bb(1);
end
end
end
H(1:es(1),:)=[]; % This line uptades the Table 2 by deleting the old data.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!