FEM 2D Truss Problem

版本 1.0.0.0 (1.7 KB) 作者: Sajeer Modavan
This code may help you to find the displacement and reactions in each element.
579.0 次下载
更新时间 2015/12/1

查看许可证

% MATLAB Code for 2D Truss to find displacement and reactions using FEM
% =====================================================================
clear;
clc;

% Example: 2
% ===========
ND = [1 2 3 4 5]; % Node Number
NE = [1 2 3 4 5 6 7]; % Element Number
NC = [1 2;2 3;3 4;4 5;1 4;2 5;2 4]; % Node Connectivity
EL = [1 1 sqrt(2) 1 sqrt(2) sqrt(2) 1]; % Member Length (m)
alf = [0 0 3*pi/4 pi pi/4 3*pi/4 pi/2]; % Member Angle
E = 2.1E11; % Youngs Modulus (N/m2)
A = pi*(12.5/1000)^2/4; % Crossectional Ares (m2)
BC = [1 2 4 9 10]; % Boundary Condition
F_val = [0 200 -100 0 -100]; % Applied Load (kN)

n_D = length(ND);
n_E = length(NE);
dof = n_D*2;
dof_n = [(2.*ND-1)' (2.*ND)'];
KG = zeros(dof,dof);

for ii = 1:n_E
n1 = NC(ii,1);
n2 = NC(ii,2);
loc = [dof_n(n1,:) dof_n(n2,:)];
nj = length(loc);
c = cos(alf(ii));
s = sin(alf(ii));
T = [c s 0 0;-s c 0 0;0 0 c s;0 0 -s c];
ke = (E*A/EL(ii)).*[1 0 -1 0;0 0 0 0;-1 0 1 0;0 0 0 0];
Ke = T'*ke*T;
for jj = 1:nj
l1 = loc(jj);
for kk = 1:nj
l2 = loc(kk);
KG(l1,l2) = KG(l1,l2)+Ke(jj,kk);
end
end
end

K_temp = KG;
for jj = 1:length(BC)
K_temp(:,BC(jj)) = 0;
K_temp(BC(jj),:) = 0;
end
K_temp(~any(K_temp,2),:) = [];
K_temp(:,~any(K_temp,1)) = [];
KR = K_temp;

FR = F_val';
UR = KR\(FR.*1000);
UR = UR.*1000;
UG = [0 0 UR(1) 0 UR(2) UR(3) UR(4) UR(5) 0 0]';
Rc = (KG*(UG/1000))/1000;
disp('Displacement in mm')
disp(UR)
disp('Reaction in kN')
disp(Rc)

引用格式

Sajeer Modavan (2024). FEM 2D Truss Problem (https://www.mathworks.com/matlabcentral/fileexchange/54258-fem-2d-truss-problem), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2007b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Structural Analysis 的更多信息
标签 添加标签
致谢

启发作品: create simple GUI

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0