MATLAB Code For Drawing SF, BM, Slope and Deflection Diagrams
MATLAB Code For Drawing SF, BM, Slope and Deflection Diagrams
𝑤𝐿
𝑅𝑒𝑐𝑎𝑡𝑖𝑜𝑛 𝑓𝑜𝑟𝑐𝑒 𝑎𝑡 𝐴 = 𝑅 = ;
6
𝑤𝐿
𝑅𝑒𝑐𝑎𝑡𝑖𝑜𝑛 𝑓𝑜𝑟𝑐𝑒 𝑎𝑡 𝐵 = 𝑅 =
3
𝒘𝒙𝟑
𝑴(𝒙) = 𝑹𝑨 𝒙 − 𝒇𝒐𝒓 𝟎 ≤ 𝒙 ≤ 𝑳
𝟔𝑳
𝑑 𝑦
𝐸𝐼 = 𝑀(𝑥)
𝑑𝑥
𝑑𝑦 1
𝑠𝑙𝑜𝑝𝑒(𝑥) = = 𝑀(𝑥)
𝑑𝑥 𝐸𝐼
1
𝑑𝑒𝑓𝑙𝑒𝑐𝑡𝑖𝑜𝑛(𝑥) = 𝑦(𝑥) = 𝑀(𝑥)
𝐸𝐼
𝑎𝑡 𝑥 = 0 , 𝑦 = 0 ; 𝑎𝑡 𝑥 = 𝐿, 𝑦 = 0;
Example
E=2*(10^11);
I=10^(-4);
w is UDL intensity in N/mm
w=5000;
L=5;
MATLAB code for simply supported beam with point load ‘W’ at a distance ‘a’ from extreme left side of beam
(a) To draw Shear Force, Bending Moment, slope and deflection diagrams
(b) To find out location of maximum deflection and its value
Input parameters:
E=Youngs Modulus or Modulus of elasticity in Pascals or N/m2
I=Area moment of inertia in m4
L=Length of beam in meters
w=Intensity of point load w in N/m
Example:
E=2*(10^11);
I=10^(-4);
w=5000;
L=5;
MATLAB code:
%simply supported beam with UVL uniformly varying load
clear all;
clc;
E=input('Youngs Modulus or Modulus of elasticity in Pascals \n E=');
I=input('Area moment of inertia in m^4\n I=');
L=input('Length of beam in meters \n L=');
w=input('Intensity of point load w in N/m \n w=');
Ra=(w*L/6);
Rb=(0.5*w*L)-Ra;
syms x M(x);
syms C1 C2 C3;
syms slope(x);
M(x)=(Ra*x)-((w*(x)^3)/(6*L));
%first section
format long;
SF(x)=diff(M(x),x);
deflection(x,C2,C3)=((int(int(M(x),x),x))+(C2*x)+C3)/(E*I);
D1y(x,C2,C3)=diff(deflection,x);
eq2 =deflection(0,C2,C3) == 0;
eq3 =deflection(L,C2,C3) == 0;
[aa,bb]= vpasolve([eq2,eq3],[C2,C3]);
C2=eval(aa);
C3=eval(bb);
deflection(x)=deflection(x,C2,C3);
slope(x)=diff(deflection(x),x);
X=0:0.1:L;
figure
area(X,double(SF(X)))
ylabel('Shear Force in N');
xlabel('Location on beam from extreme left along length in m');
figure
area(X,double(M(X)))
ylabel('Bending Moment in N-m');
xlabel('Location on beam from extreme left along length in m');
figure
area(X,double(slope(X)))
ylabel('Slope of bend curvature of beam');
xlabel('Location on beam from extreme left along length in m');
figure
plot(X,double(deflection(X)))
ylabel('Deflection in m');
xlabel('Location on beam from extreme left along length in m');
% Maximum Bending Moment
BM_max_loc=vpasolve(diff(M(x),x)==0,x,[0,L]);
BM_max_loc=eval(BM_max_loc);
max_BM=double(M(BM_max_loc));
fprintf('Maximum BM is at %f m from extreme left side of beam \n',BM_max_loc);
fprintf('Maximum BM is %f N-m \n',max_BM);
% Maximum deflection
Def_max_loc=vpasolve(diff(deflection(x),x)==0,x,[0,L]);
Def_max_loc=eval(Def_max_loc);
max_def=double(deflection(Def_max_loc));
fprintf('Maximum deflection is at %f m from extreme left side of beam \n',Def_max_loc);
fprintf('Maximum deflection is %f m \n',max_def);
Shear Force in N
OUTPUT
Deflection in m
Maximum BM is at 2.886751 m from extreme left side of beam