You are on page 1of 3

The following analysis resulted into the drawing of the bending m oment

and shear force diagram for beam loaded as indicated in the figure right
next.
Write a function that will allow you to redraw the both the shear force
and bending mom ent diagrams.
Apply your program and pick any along the span of the beam and
check if your results m ake sense.
2021/05/12 4:46 PM C:\Users\DF Sozinando\D...\beam1.m 1 of 2

clc
clear
close all

%Data
FA=20;%kN
FC=40;%kN
LAB=2.5;%m
LBC=3;%m
LCD=2;%m
L=7.5;%m
E=200*10^6;%kPa
I=24*10^-6;%m^4

%Reaction
syms RB RD %Unknowns
%Sum of moment at D
equ1=-FA*(LAB+LBC+LCD)+RB*(LBC+LCD)-FC*LCD==0;
%Sum of moment at B
equ2=-FA*LAB+FC*LBC-RD*(LBC+LCD)==0;
%Solving RB and RD
[RB RD]=solve([equ1 equ2],[RB RD]);
RB=double(RB)
RD=double(RD)
%Range of x
dx=0.001; % Increment for discretization of beam length
x=0:dx:L; % range variable of beam length

%processing BM and SF programming loop at each section


for i=1:length(x)
% First portion of the beam
if 0<=x(i)&&x(i)< LAB
M(i)=-FA*x(i);
% Second portion of the beam
elseif LAB<=x(i)&&x(i)<LAB+LBC
M(i)=-FA*x(i)+RB*(x(i)-LAB);
elseif LAB+LBC<=x(i)&&x(i)<=LAB+LBC+LCD
% Second portion of the beam
M(i)=-FA*x(i)+RB*(x(i)-LAB)-FC*(x(i)-LAB-LBC);
end
end
%Shear force
V=@(x)diff(M)/dx;
figure(1)
subplot(2,1,1)
bar(x,[V(x),NaN]);
xlabel('Length [m]')
ylabel('SF [kN]')
title('Shear Force Diagram')
grid on

subplot(2,1,2)
bar(x,M);
2021/05/12 4:46 PM C:\Users\DF Sozinando\D...\beam1.m 2 of 2

xlabel('Length [m]')
ylabel('BM [kNm]')
title('Bending Moment Diagram')
set(gcf,'color','white');
box on;
grid on;

%Numerical Integration
slope0=cumtrapz(M)*dx;
deflect0=cumtrapz(slope0)*dx;

%Boundary condintion
%n=((last-first)/dx)+1
x1=2.5;
x2=7.5;
n1=((x1-0)/dx)+1;
n2=((x2-0)/dx)+1;
%Finding constant C
C=-[x1,1;x2,1]\[deflect0(n1);deflect0(n2)];

%Slope and deflection equation


slope=(slope0+C(1))/(E*I);
y=(deflect0+C(1)*x+C(2))/(E*I);

figure(2)
subplot(2,1,1)
plot(x,slope);
xlabel('Length [m]')
ylabel('slope [rad]')
title('Slope Diagram')
grid on

subplot(2,1,2)
plot(x,y);
xlabel('Length [m]')
ylabel('Deflection [m]')
title('Deflection Diagram')
grid on

You might also like