You are on page 1of 7

MATLAB Command Window

>> prashik6
format compact
% Data: assume both element has a square 2X2 cross section
CID=38;d=3;r=d/2;
A=(pi*(r^2)); I=(((r^4)/4)*pi);
A1=A;A2=A;I1=I;I2=I;E=3e7;
b=5+CID;a1=4*b;a2=3*b;a4=4*b;a3=3*b;
X1=0;X2=a1;X3=(a1+a3);Y1=0;Y2=a2;Y3=(a2-a4);
%% Element 1 (Node 1 to 2)
DX=X2-X1,DY=Y2-Y1,L=sqrt(DX^2+DY^2),C1=DX/L,S1=DY/L
DX =
172
DY =
129
L =
215
C1 =
0.8000
S1 =
0.6000
L1=L;
EDOF1=[1 2 3 4 5 6];
VPY=-5;VPaxial=VPY*S1;c0=VPaxial % Note the negtive sign
c0 =
-3
c1=0;
VPbend=VPY*C1
VPbend =
-4
cb0=VPbend % Note the negtive sign
cb0 =
-4
cb1=0;
c=C1;s=S1;A=A1;L=L1;
[Ke,Pe,PeG,T]=Frame_KLoad(E,I,L,A,c0,c1,cb0,cb1,c,s)
t =
0.8000
0.6000
0
-0.6000
0.8000
0
0
0
1.0000
z =
0
0
0
0
0
0
0
0
0
T =
0.8000
0.6000
0
0
0
0
-0.6000
0.8000
0
0
0
0
0
0
1.0000
0
0
0
0
0
0
0.8000
0.6000
0
0
0
0
-0.6000
0.8000
0
0
0
0
0
0
1.0000
Ke =

Page 1

MATLAB Command Window


1.0e+06 *
0.9863
0
0
-0.9863
0
0
0.0001
0.0155
0
-0.0001
0
0.0155
2.2192
0
-0.0155
-0.9863
0
0
0.9863
0
0
-0.0001
-0.0155
0
0.0001
0
0.0155
1.1096
0
-0.0155
Pe =
1.0e+04 *
-0.0323
-0.0430
-1.5408
-0.0323
-0.0430
1.5408
PeG =
1.0e+04 *
0
-0.0537
-1.5408
0
-0.0537
1.5408
T =
0.8000
0.6000
0
0
0
-0.6000
0.8000
0
0
0
0
0
1.0000
0
0
0
0
0
0.8000
0.6000
0
0
0
-0.6000
0.8000
0
0
0
0
0
KE1=T'*Ke*T
KE1 =
1.0e+06 *
0.6313
0.4734
-0.0093
-0.6313
-0.4734
0.4734
0.3552
0.0124
-0.4734
-0.3552
-0.0093
0.0124
2.2192
0.0093
-0.0124
-0.6313
-0.4734
0.0093
0.6313
0.4734
-0.4734
-0.3552
-0.0124
0.4734
0.3552
-0.0093
0.0124
1.1096
0.0093
-0.0124
Ke1=Ke;pe1=Pe;T1=T;
EK{1}=KE1;EDOF{1}=EDOF1;EP{1}=PeG;
%% Element 2 (Node 2 to 3)
DX=X3-X2,DY=Y3-Y2,L=sqrt(DX^2+DY^2),C2=DX/L,S2=DY/L
DX =
129
DY =
-172
L =
215
C2 =
0.6000

Page 2

0
0.0155
1.1096
0
-0.0155
2.2192

0
0
0
0
0
1.0000

-0.0093
0.0124
1.1096
0.0093
-0.0124
2.2192

MATLAB Command Window


S2 =
-0.8000
L2=L;
EDOF2=[4 5 6 7 8 9];
VPX=20;VPaxial=VPX*C2;c0=VPaxial % Note the negtive sign
c0 =
12
c1=-15*C2/L2
c1 =
-0.0419
VPbend=-VPX*S2
VPbend =
16
cb0=VPbend % Note the negtive sign
cb0 =
16
cb1=15*S2/L2
cb1 =
-0.0558
c=C2;s=S2;A=A2;
[Ke,Pe,PeG,T]=Frame_KLoad(E,I,L,A,c0,c1,cb0,cb1,c,s)
t =
0.6000
-0.8000
0
0.8000
0.6000
0
0
0
1.0000
z =
0
0
0
0
0
0
0
0
0
T =
0.6000
-0.8000
0
0
0
0
0.8000
0.6000
0
0
0
0
0
0
1.0000
0
0
0
0
0
0
0.6000
-0.8000
0
0
0
0
0.8000
0.6000
0
0
0
0
0
0
1.0000
Ke =
1.0e+06 *
0.9863
0
0
-0.9863
0
0
0
0.0001
0.0155
0
-0.0001
0.0155
0
0.0155
2.2192
0
-0.0155
1.1096
-0.9863
0
0
0.9863
0
0
0
-0.0001
-0.0155
0
0.0001
-0.0155
0
0.0155
1.1096
0
-0.0155
2.2192
Pe =
1.0e+04 *
0.0968
0.1333
4.3143
0.0645
0.0817

Page 3

MATLAB Command Window


-3.3898
PeG =
1.0e+04 *
0.1647
0.0026
4.3143
0.1041
-0.0026
-3.3898
T =
0.6000
-0.8000
0
0
0.8000
0.6000
0
0
0
0
1.0000
0
0
0
0
0.6000
0
0
0
0.8000
0
0
0
0
KE2=T'*Ke*T
KE2 =
1.0e+06 *
0.3552
-0.4734
0.0124
-0.3552
-0.4734
0.6313
0.0093
0.4734
0.0124
0.0093
2.2192
-0.0124
-0.3552
0.4734
-0.0124
0.3552
0.4734
-0.6313
-0.0093
-0.4734
0.0124
0.0093
1.1096
-0.0124
Ke2=Ke;pe2=Pe;T2=T;
EK{2}=KE2;EDOF{2}=EDOF2;EP{2}=PeG;
%% Assembly global stiffness matrix
NDOF=9;
[Kgg,Pg]=Assembly_KP(NDOF,EK,EDOF,EP);
Kgg
Kgg =
1.0e+06 *
0.6313
0.4734
-0.0093
-0.6313
0
0.4734
0.3552
0.0124
-0.4734
0
-0.0093
0.0124
2.2192
0.0093
0
-0.6313
-0.4734
0.0093
0.9865
0.0124
-0.4734
-0.3552
-0.0124
0
0.0093
-0.0093
0.0124
1.1096
0.0217
1.1096
0
0
0
-0.3552
-0.0124
0
0
0
0.4734
-0.0093
0
0
0
0.0124
2.2192

Page 4

0
0
0
-0.8000
0.6000
0

0
0
0
0
0
1.0000

0.4734
-0.6313
-0.0093
-0.4734
0.6313
-0.0093

0.0124
0.0093
1.1096
-0.0124
-0.0093
2.2192

-0.4734

-0.0093

-0.3552

0.0124

-0.0124

1.1096

0.0217

-0.3552

0.4734

0.9865

-0.0031

0.4734

-0.6313

-0.0031

4.4384

-0.0124

-0.0093

0.4734

-0.0124

0.3552

-0.4734

-0.6313

-0.0093

-0.4734

0.6313

0.0093

1.1096

-0.0124

-0.0093

MATLAB Command Window


Pg1=Pg
Pg1 =
1.0e+04 *
0
-0.0537
-1.5408
0.1647
-0.0512
5.8552
0.1041
-0.0026
-3.3898
%% Define concentrated nodal loads
%Global Loads
PgC=[0;0;0;0;0;0;0;0;0]
PgC =
0
0
0
0
0
0
0
0
0
Pg=PgC+Pg1
Pg =
1.0e+04 *
0
-0.0537
-1.5408
0.1647
-0.0512
5.8552
0.1041
-0.0026
-3.3898
%% Define BC
IDS=[1 2 3 7 8 9];IDF=[4 5 6];
%% Apply BC
Kff=Kgg(IDF,IDF)
Kff =
1.0e+06 *
0.9865
0
0.0217
0
0.9865
-0.0031
0.0217
-0.0031
4.4384
Pf=Pg(IDF)
Pf =
1.0e+04 *
0.1647
-0.0512

Page 5

MATLAB Command Window

Page 6

5.8552
%% Solution for displacement
Uf=Kff\Pf
Uf =
0.0014
-0.0005
0.0132
Ug=zeros(NDOF,1);Ug(IDF)=Uf
Ug =
0
0
0
0.0014
-0.0005
0.0132
0
0
0
%% Compute reactions
Reac=Kgg(IDS,IDF)*Uf-Pg(IDS)
Reac =
1.0e+04 *
-0.0768
0.0217
3.0057
-0.1920
0.0858
4.8541
Reac1=Kgg(IDS,IDF)*Uf
Reac1 =
1.0e+04 *
-0.0768
-0.0320
1.4649
-0.0879
0.0832
1.4643
%% Check Equilibrium
SumFx=sum(Pg(1:3:9))+sum(Reac([1 4]))
SumFx =
4.5475e-13
SumFy=sum(Pg(2:3:9))+sum(Reac([2 5]))
SumFy =
2.2737e-13
SumMA=Reac(3)+Reac(6)+Pg(3)+Pg(6)+Pg(9)+(Reac(4)*(-Y3))+(Reac(5)*(X3))+(-Pg(4)*a2)+(Pg(5)
*a1)+(Pg(7)*(-Y3))+(Pg(8)*X3)
SumMA =
-2.2737e-11
%%USE Bar and Beam Shape Functions to find displacement at P
DXa=X2-X1;DYa=Y2-Y1;La=sqrt(DXa^2+DYa^2);x=La/2
x =

MATLAB Command Window


107.5000
Nbar=[1-x/La x/La]';
N1beam=((2*x^3)/La^3)-((3*x^2)/La^2)+1;Nd1=((6*x^2)/La^3)-((6*x)/La^2);
N2beam=x-((2*x^2)/La)+((x^3)/La^2);Nd2=((3*x^2)/La^2)-((4*x)/La)+1;
N3beam=((3*x^2)/La^2)-((2*x^3)/La^3);Nd3=((-6*x^2)/La^3)+((6*x)/La^2);
N4beam=(x^3/La^2)-(x^2/La);Nd4=((3*x^2)/La^2)-(2*x/La);
Nbeam=[N1beam N2beam N3beam N4beam]';
Ndbeam=[Nd1 Nd2 Nd3 Nd4]';
ID1=[1 2 3 4 5 6];
bar=[1 4];beam=[2 3 5 6];
U=Ug(ID1)
U =
0
0
0
0.0014
-0.0005
0.0132
Px=Nbar'*U(bar)
Px =
6.8989e-04
Py=Nbeam'*U(beam)
Py =
-0.3546
Prot=Ndbeam'*U(beam)
Prot =
-0.0033
>>

Page 7

You might also like