code for fem -constrained bar

I was trying to write a code for a horizontal two step bar constrained at both ends to determine its deflection at the three nodes and reactionary forces at the ends.At node 2 an axial force of 2kN is applied.I am clueless how to go about writing the code.Everytime I run it an error pops up.Can somebody guide me
% static analysis
%material properties
E=[70e9,200e9];
%Geometry
L=700e-3;
A=[2400e-6,600e-6];
q0=0;
%Element mesh
ne=2; %no.of elements
nn=3; %no.of nodes
dof=1; %degrees of freedom per node
tdof=dof*nn; % total degree of freedom
le=[300e-3,400e-3]; %length of elements
% Initialization of Global Matrices
KG=zeros(tdof,tdof); %global stiffness matrix
FG = zeros(tdof,1); % global load vector
%assembly of global matrices
for i= 1:ne
Ke(i)=(E(i)*A(i)/le(i))*[1 -1;-1 1]; % element stiffness matrix
Fe=(q0*le(i)/2)*[1;1]; % element load vector for udl
for j=1:2
for k=1:2
KG(CONN(i,j),CONN(i,k))= KG(CONN(i,j),CONN(i,k))+Ke(i);
end
FG(CONN(i,j),1)= FG(CONN(i,j),1)+Fe(i,j);
end
end
CONN=[1 2;2 3];
KG(1,:)=0;
KG(:,1)=0;
KG(1,1)=1;
KG(3,:)=0;
KG(:,3)=0;
KG(3,3)=0;
FG(3,1)=0;
For m=[1,3];
KG(m,:)=0;
KG(:,m)=0;
KG(m,m)=1;
FG(m,1)=0;
End
UG=linsolve(KG,FG);

6 件のコメント

darova
darova 2020 年 2 月 25 日
What does it mean?
Syed Haque
Syed Haque 2020 年 2 月 25 日
constrained nodes where deflection is zero
darova
darova 2020 年 2 月 25 日
This instruction doesn't work (somehow)
Did it work for you?
Syed Haque
Syed Haque 2020 年 2 月 26 日
no and I am looking for clues in this forum
darova
darova 2020 年 2 月 26 日
These two statements look familiar for me
What do you think?
Syed Haque
Syed Haque 2020 年 2 月 26 日
The first one is for element stiffness matrix
and second is reduced or condensed global stiffness matrix after imposition of boundary conditions

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

回答 (0 件)

カテゴリ

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

質問済み:

2020 年 2 月 25 日

コメント済み:

2020 年 2 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by