0% found this document useful (0 votes)
27 views

MATLAB Command Window: All X L

The document shows MATLAB code that is calculating the stiffness matrix and forces for a beam element problem. It defines symbolic variables, material properties, the beam cross section properties, and the displacement shape functions. It then calculates the stiffness matrix for two elements of different lengths and the applied loads, and solves the system of equations to find the reaction forces and displacements at the ends of the elements.

Uploaded by

Himanshu Khatri
Copyright
© © All Rights Reserved
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)
27 views

MATLAB Command Window: All X L

The document shows MATLAB code that is calculating the stiffness matrix and forces for a beam element problem. It defines symbolic variables, material properties, the beam cross section properties, and the displacement shape functions. It then calculates the stiffness matrix for two elements of different lengths and the applied loads, and solves the system of equations to find the reaction forces and displacements at the ends of the elements.

Uploaded by

Himanshu Khatri
Copyright
© © All Rights Reserved
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/ 1

MATLAB Command Window Page 1

>> clear all


syms x L;
E=3e7;
I=(2*(4^3))/12;f=[1 x x^2 x^3];
p1=20+(0.3*x);p2=35+(0.3*x);
df=diff(f,x);
A=[subs(f,x,0);subs(df,x,0);subs(f,x,L);subs(df,x,L)];
AI=inv(A);
N=f*AI;
Nb=diff(diff(N));
NtN=transpose(Nb)*Nb;
Ke=E*I*int(NtN,x,0,L);
Ke1=subs(Ke,L,50);
Ke2=subs(Ke,L,50);
P1=int(p1*transpose(N),0,50);
P2=int(p2*transpose(N),0,50);
Pe1=subs(P1,L,50);
Pe2=subs(P2,L,50);
ID1=[1 2 3 4];ID2=[3 4 5 6];
Kgg=zeros(6,6);Pg=zeros(6,1);Ug=zeros(6,1);
Kgg(ID1,ID1)=Kgg(ID1,ID1)+Ke1;
Kgg(ID2,ID2)=Kgg(ID2,ID2)+Ke2;
IDS=[1 2 5 6];
IDF=[3 4];
Pg(ID1)=Pg(ID1)+Pe1;
Pg(ID2)=Pg(ID2)+Pe2;
Kff=Kgg(IDF,IDF);
Pf=Pg(IDF);
Uf=Kff\Pf;
Ug(IDF)=Uf;
Ps=Pg(IDS);
Us=Ug(IDS);
R=-Ps+Kgg(IDS,IDF)*Uf;
R
Uf

R =

1.0e+04 *

-0.1450
-2.6667
-0.2050
3.1667

Uf =

0.0285
0.0000

>>

You might also like