Finite Elements Method creating global stiffness matrix

22 ビュー (過去 30 日間)
ömer altay
ömer altay 2019 年 3 月 15 日
コメント済み: Yago Trias Vila 2022 年 9 月 19 日
Hi everyone, I am really stuck in creating a code that creates global stiffness matrix that changing local stiffness matrixes value in every cycle.
For example it has to be
k1 -k1 0 0
-k1 k1+k2 - k2 0
0 - k2 k2+k3 -k3
0 0 -k3 k3
but my code doesn't change k1 to k2 for next step ... it only calculates for k1.
k1 -k1 0 0
-k1 k1+k1 - k1 0
0 - k1 k1+k1 -k1
0 0 -k1 k1
Please help me to solve this problem. Thanks.
clear
tp=[1 2]
for i=2:4
tp(i,:)=tp(i-1,:)+1
end
tpmax=max(max(tp));
KG=zeros(tpmax,tpmax);
for i=1:4
d(i)=32+(28/1200)*(2*i-1)*50
G(i)=(77000*pi*d(i).^4)/3200
k=[G(i) -G(i);-G(i) G(i)]
end
for n=1:4
i=n+[0 1]
j=i
KG(i,j)=KG(i,j)+k
end
  2 件のコメント
Mehmet Ali kurt
Mehmet Ali kurt 2020 年 4 月 27 日
Hi Omer ; If you have solition of 'Derived stiffness matrix for 1D 3-Nodes elements' can you send me please ?
Ghazi Fanar
Ghazi Fanar 2021 年 7 月 30 日
Answer

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

採用された回答

Stephan
Stephan 2019 年 3 月 15 日
編集済み: Stephan 2019 年 3 月 15 日
Hi,
you overwrite k every time. Im sure it could be done much easier - but here s a quick solution without any code optimization (Matlab users usually try to avoid for loops...):
clear
tp=[1 2];
for i=2:4
tp(i,:)=tp(i-1,:)+1;
end
tpmax=max(max(tp));
KG=zeros(tpmax,tpmax);
for i=1:4
d(i)=32+(28/1200)*(2*i-1)*50;
G(i)=(77000*pi*d(i).^4)/3200;
k(:,:,i)=[G(i) -G(i);-G(i) G(i)];
end
for n=1:4
i=n+[0 1];
j=i;
KG(i,j)=KG(i,j)+k(:,:,n);
end
Result is:
KG =
1.0e+08 *
0.9147 -0.9147 0 0 0
-0.9147 2.1154 -1.2006 0 0
0 -1.2006 2.7494 -1.5488 0
0 0 -1.5488 3.5165 -1.9677
0 0 0 -1.9677 1.9677
I think this is what you expected.
Best regards
Stephan
  3 件のコメント
Stephan
Stephan 2019 年 3 月 16 日
If my answer was useful, please accept it.
Yago Trias Vila
Yago Trias Vila 2022 年 9 月 19 日
Exactly what I needed, Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by