Static Example:: Matlab Code
Static Example:: Matlab Code
Matlab Code
%close all
clear all
clc
EI =30e9*.2*.4^3/12;
L=6;
P=10e4;
% Zero matrices
KG1=zeros(6,6);
KG2=zeros(6,6);
% Local matrices
K1=EI/L*[12/L.^2, 6/L, -12/L.^2, 6/L; 6/L, 4, -6/L, 2; -12/L.^2, -6/L, 12/L.^2, -6/L; 6/L, 2,-6/L, 4];
K2=EI/L*[12/L.^2, 6/L, -12/L.^2, 6/L; 6/L, 4, -6/L, 2; -12/L.^2, -6/L, 12/L.^2, -6/L; 6/L, 2,-6/L, 4];
KG1([1,2,3,4],[1,2,3,4])=K1;
KG2([3,4,5,6],[3,4,5,6])=K2;
% Globalization
KG=KG1+KG2;
KG=KG([2,3,4,6],[2,3,4,6]);
FG=[0;P;0;0];
% The equation
U=inv(KG)*FG
Now, each step with its MATLAB result (just for clarification)
%close all
clear all
clc
EI =30e9*.2*.4^3/12;
L=6;
P=10e4;
% Zero matrices
KG1=zeros(6,6);
KG2=zeros(6,6);
% Local matrices
K1=EI/L*[12/L.^2, 6/L, -12/L.^2, 6/L; 6/L, 4, -6/L, 2; -12/L.^2, -6/L, 12/L.^2, -6/L; 6/L, 2,-6/L, 4];
K2=EI/L*[12/L.^2, 6/L, -12/L.^2, 6/L; 6/L, 4, -6/L, 2; -12/L.^2, -6/L, 12/L.^2, -6/L; 6/L, 2,-6/L, 4];
% Putting the locals inside the zeros
KG1([1,2,3,4],[1,2,3,4])=K1;
KG2([3,4,5,6],[3,4,5,6])=K2;
% Globalization
KG=KG1+KG2;
KG=KG([2,3,4,6],[2,3,4,6]);
FG=[0;P;0;0];
% The equation
U=inv(KG)*FG