Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
238 views2 pages

Beam Matlab Code

This code defines a function to model a bar element with a given modulus of elasticity, cross-sectional area, and length divided into a number of elements. It calculates the local and global stiffness matrices, applies a load at a specified node, and calculates the resulting displacements by inverting the global stiffness matrix.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
238 views2 pages

Beam Matlab Code

This code defines a function to model a bar element with a given modulus of elasticity, cross-sectional area, and length divided into a number of elements. It calculates the local and global stiffness matrices, applies a load at a specified node, and calculates the resulting displacements by inverting the global stiffness matrix.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

function f=bar

E= input('Enter modulus of elasticity E [N/m^2] =.....');


A= input ('Enter area of cross section A [mm^2]=.....');
L= input ('Enter length of bar L [mm]=.....');
n= input('Enter number of Elements n=.....')
l=L/n;
konst=(E*A)/l;
xke=zeros(2); %local stiffness matrix
xke(1,1)=1*l; xke(1,2)=-1*l;xke(2,1)=-1*l;xke(2,2)=1*l;
xke
xue=zeros(2,1); %local stiffness matrix
xue(1,1)=1*l; xue(2,1)=-1*l;
xue
dof= input('Enter number of Dof per eliment Dof=.....')
gdof=(dof*n)+1
xk=zeros(gdof);
for k=1:n
% code numbers of k-the element
ic=[k k+1];
% assembling
xk(ic,ic)=xk(ic,ic)+xke;
end
xk;
K=xk*konst
force=zeros(gdof,1)
n1= input('applied load at node n1=.....')
P= input('applied load at nodes P=....')

BC=input('Enter prescribed dofs=....');


% free Dof : activeDof
force(n1)=P
xu=zeros(gdof,1);
nn=size(n1);
nn1=nn(:,2);
for A=1:nn1
n1(A);
xu(n1(A))= force(n1(A))/xk(n1(A),n1(A));

%xu(BC)=0
%xu
%xk(:,n1)
rection=xu(n1(A))*xk(:,n1(A))-force;
%F=rection+force
end
rection

You might also like