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
2020-2-25
What does it mean?

Syed Haque
2020-2-25
darova
2020-2-25
This instruction doesn't work (somehow)
Did it work for you?
Syed Haque
2020-2-26
darova
2020-2-26
These two statements look familiar for me

What do you think?
Syed Haque
2020-2-26
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
