0% found this document useful (0 votes)
16 views6 pages

Static Example:: Matlab Code

This Matlab code calculates the deflection of a beam under a applied load. It defines material properties and beam dimensions, calculates the stiffness matrix of the beam element, applies boundary conditions, and uses matrix inversion to solve for the deflection. The code breaks the beam into two elements, calculates local stiffness matrices, combines them into a global matrix, applies the load vector, and solves for the displacement vector.

Uploaded by

Mariwan Mir
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)
16 views6 pages

Static Example:: Matlab Code

This Matlab code calculates the deflection of a beam under a applied load. It defines material properties and beam dimensions, calculates the stiffness matrix of the beam element, applies boundary conditions, and uses matrix inversion to solve for the deflection. The code breaks the beam into two elements, calculates local stiffness matrices, combines them into a global matrix, applies the load vector, and solves for the displacement vector.

Uploaded by

Mariwan Mir
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/ 6

Static Example:

Matlab Code

%close all

clear all
clc

% Input the necessary Data

EI =30e9*.2*.4^3/12;
L=6;
P=10e4;

% Stiffness Matrix for the beam

% 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;

% Applying the boundary conditions

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

% Input the necessary Data

EI =30e9*.2*.4^3/12;
L=6;
P=10e4;

% Stiffness Matrix for the beam

% 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;

% Applying the boundary conditions

KG=KG([2,3,4,6],[2,3,4,6]);

FG=[0;P;0;0];
% The equation

U=inv(KG)*FG

You might also like