How to wirte algorithm for meshing line element?

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

 採用された回答

hamit Kenan
hamit Kenan 2019 年 4 月 20 日

0 投票

ı solved it :)
Anyone who needs the same algorithm can send message to me.

2 件のコメント

Angkur Shaikeea
Angkur Shaikeea 2021 年 3 月 9 日
Can you share your method please? is it vectorised?
hamit Kenan
hamit Kenan 2021 年 3 月 9 日
編集済み: hamit Kenan 2021 年 3 月 9 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructural Analysis についてさらに検索

質問済み:

2019 年 4 月 18 日

編集済み:

2021 年 3 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by