summaryrefslogtreecommitdiff
path: root/3588/CH2/EX2.6/EX2_6.sce
blob: 416b7c1d5fd03c9b40204cd51d899d1eee94bfa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Clearing Console
clc
clear

//Node 1 Displacement
U1=0

//Stiffness of Springs
k1=4
k2=6
k3=3

//Nodal Forces
F2=-30
F3=0
F4=50

//varible decleration
K=zeros(3,3)

//Constructing Stiffness and Force matrices
K(1,1)=k1 + 2*k2
K(1,2)=-2*k2
K(2,1)=-2*k2
K(2,2)=2*k2 +k3
K(2,3)=-k3
K(3,2)=-k3
K(3,3)=k3

F(1,1)=F2
F(2,1)=F3
F(3,1)=F4

//Solving for Nodal Displacements U2, U3 and U4
U=linsolve(K,-F) //K*U=F (equlibrium equation)

//Solving for Nodal force F1
F1=-4*U(1,1)

//Printing Results
printf('\nResults\n')
printf('\nNodal displacements \nU1=%fmm \nU2=%fmm \nU3=%fmm \nU4=%fmm\n',U1,U(1,1),U(2,1),U(3,1))
printf('\nNodal Force F1=%fN\n',F1)