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 Exchange에서 Programming에 대해 자세히 알아보기

질문:

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