You are on page 1of 7

SE LAB Assignment 2017-CIV-61

clc
clear all
disp ('SFD and BMD for the selected Beam')

%Code for Input of Data


LoadType = input ('Type of Load on the Beam (Point Load = 1, UDL = 2, VDL =
3, All Loads = 4) = ');
if LoadType == 1; %Input of Point Load Data
LP = input('Length of Beam (m) = ');
WP = input('Load Applied (kN) = ');
aP = input('Location of Load from Left End of the Beam (m) = ');
cP = LP-aP;
R1P = (WP*cP^2/LP^3)*(3*aP+cP); % Left Support Reaction.
M1P= (WP*aP*cP^2)/LP^2; % Left Support Moment.
R2P = (WP*aP^2/LP^3)*(aP+3*cP); % Right Support Reaction.
M2P= (WP*aP^2*cP)/LP^2; % Right Support Moment.

elseif LoadType == 2; %Input of UDL Data


LU = input('Length of Beam (m) = ');
WU = input('UDL (kN/m) = ');
dU = input('Length of UDL (meter) = ');
cgU = input('C.G. of UDL from Left End of the Beam (m) = ');
aU = cgU-dU/2;
bU = LU-cgU;
cU = LU-aU-bU;
R1U = (WU*dU/LU^3)*((2*cgU+LU)*bU^2+((cgU-bU)/4)*dU^2); % Left Support
Reaction.
M1U= (WU*dU/LU^2)*(cgU*bU^2+((cgU-2*bU)*dU^2)/12);% Left Support Moment.
R2U = (WU*dU/LU^3)*((2*bU+LU)*cgU^2-((cgU-bU)/4)*dU^2); % Right Support
Reaction.
M2U= (WU*dU/LU^2)*(cgU^2*bU+((bU-2*cgU)*dU^2)/12);% Right Support Moment.

elseif LoadType == 3; %Input of VDL Data


LV = input('Length of Beam (m) = ');
WV = input('Maximum Ordinate of VDL (kN) = ');
cV = input('Length of VDL (meter) = ');
bV = input('Position of Max. VDL from Left End of the Beam (m) = ');
aV = bV-cV;
dV = LV-aV-(2*cV/3);
R1V = (WV*cV)/(2*LV^3)*(dV^2*(3*LV-2*dV)-cV^2*(LV/2-bV+17*cV/45)/3); %
Left Support Reaction.
M1V= -(WV*cV)/(2*LV^2)*(dV^2*(dV-LV)+cV^2*(LV/3+(17*cV/90)-bV/2)/3); %
Left Support Moment.
R2V = WV*cV/2-R1V; % Right Support Reaction.
M2V= (WV*cV)/(2*LV^2)*(dV*(dV-LV)^2+cV^2*(LV/3+(17*cV/45)-bV)/6); % Right
Support Moment.

elseif LoadType == 4; %Input of All Loads Data


L = input('Length of Beam (m) = ');
WP = input('Point Load Applied (kN) = ');
aP = input('Location of Point Load from Left End of the Beam (m) = ');
cP = L-aP;
WU = input('UDL (kN/m) = ');
dU = input('Length of UDL (meter) = ');
cgU = input('C.G. of UDL from Left End of the Beam (m) = ');
aU = cgU-dU/2;
bU = L-cgU;
cU = L-aU-bU;

WV = input('Maximum Ordinate of VDL (kN) = ');


cV = input('Length of VDL (meter) = ');
bV = input('Position of Max. VDL from Left End of the Beam (m) = ');
aV = bV-cV;
dV = L-aV-(2*cV/3);

% Reactions against Individual Point Load


R1P = (WP*cP^2/L^3)*(3*aP+cP); % Left Support Reaction.
M1P= (WP*aP*cP^2)/L^2; % Left Support Moment.
R2P = (WP*aP^2/L^3)*(aP+3*cP); % Right Support Reaction.
M2P= (WP*aP^2*cP)/L^2; % Right Support Moment.

% Reactions against Individual UDL


R1U = (WU*dU/L^3)*((2*cgU+L)*bU^2+((cgU-bU)/4)*dU^2); % Left Support
Reaction.
M1U= (WU*dU/L^2)*(cgU*bU^2+((cgU-2*bU)*dU^2)/12);% Left Support Moment.
R2U = (WU*dU/L^3)*((2*bU+L)*cgU^2-((cgU-bU)/4)*dU^2); % Right Support
Reaction.
M2U= (WU*dU/L^2)*(cgU^2*bU+((bU-2*cgU)*dU^2)/12);% Right Support Moment.

% Reactions against Individual VDL


R1V = (WV*cV)/(2*L^3)*(dV^2*(3*L-2*dV)-cV^2*(L/2-bV+17*cV/45)/3); % Left
Support Reaction.
M1V= -(WV*cV)/(2*L^2)*(dV^2*(dV-L)+cV^2*(L/3+(17*cV/90)-bV/2)/3); % Left
Support Moment.
R2V = WV*cV/2-R1V; % Right Support Reaction.
M2V= (WV*cV)/(2*L^2)*(dV*(dV-L)^2+cV^2*(L/3+(17*cV/45)-bV)/6); % Right
Support Moment.

% Reactions against Combined Loading


R1 = ((WP*cP^2/L^3)*(3*aP+cP))+((WU*dU/L^3)*((2*cgU+L)*bU^2+((cgU-
bU)/4)*dU^2))+((WV*cV)/(2*L^3)*(dV^2*(3*L-2*dV)-cV^2*(L/2-bV+17*cV/45)/3)); %
Left Support Reaction.
M1= ((WP*aP*cP^2)/L^2)+((WU*dU/L^2)*(cgU*bU^2+((cgU-2*bU)*dU^2)/12))+(-
(WV*cV)/(2*L^2)*(dV^2*(dV-L)+cV^2*(L/3+(17*cV/90)-bV/2)/3)); % Left Support
Moment.
R2 = ((WP*aP^2/L^3)*(aP+3*cP))+((WU*dU/L^3)*((2*bU+L)*cgU^2-((cgU-
bU)/4)*dU^2))+(WV*cV/2-R1V); % Right Support Reaction.
M2= ((WP*aP^2*cP)/L^2)+((WU*dU/L^2)*(cgU^2*bU+((bU-
2*cgU)*dU^2)/12))+((WV*cV)/(2*L^2)*(dV*(dV-L)^2+cV^2*(L/3+(17*cV/45)-bV)/6));
% Right Support Moment.

elseif (LoadType>4||LoadType<1)
error('Please input Number btween 1 and 4')
end

% Discretization of x axis.
n=1000; % Number of discretization of x-axis.
if LoadType == 1
x = (0:LP/n:LP)'; % Generate column array for Point Load x-axis.
elseif LoadType == 2
x = (0:LU/n:LU)'; % Generate column array for UDL x-axis.
elseif LoadType==3
x = (0:LV/n:LV)'; % Generate column array for VDL x-axis.
else
x = (0:L/n:L)'; % Generate column array for Combined Load x-axis.
end

V = zeros(size(x, 1), 1); % Shear force function of x.


M = zeros(size(x, 1), 1); % Bending moment function of x.

%Code for Calculations of SFD and BMD


if LoadType == 1; %Code for Point Load Calculations
for i = 1:n+1; % First portion of the beam, 0 < x < aP
V(i) = R1P;
M(i) = -M1P+R1P*x(i); % Second portion of the beam, aP < x < L
if x(i) >= aP
V(i) = R1P-WP;
M(i) = -M1P+R1P*x(i)-WP*(x(i)-aP);
end
end
x1 = aP;
Mmax = -M1P+R1P*aP;

% Displaying the Reacctions for this Case


disp(' ');disp (['Left Support Reaction' ' = ' num2str(R1P) ' ' 'kN'])
disp(' ');disp (['Left Support Moment' ' = ' num2str(M1P) ' ' 'kN-m'])
disp(' ');disp (['Right Support Reaction' ' = ' num2str(R2P) ' ' 'kN'])
disp(' ');disp (['Right Support Moment' ' = ' num2str(M2P) ' ' 'kN-m'])
disp(' ');disp (['Mmax' ' = ' num2str(Mmax) ' ' 'kNm'])

elseif LoadType == 2; %Code for UDL Calculations


for i = 1:n+1
if x(i) < aU; % First portion of the beam, 0 < x < aU
V(i) = R1U;
M(i) = -M1U+R1U*x(i);
elseif aU <= x(i) && x(i)< aU+dU; % Second portion of the beam, aU <
x < aU+dU
V(i) = R1U-WU*(x(i)-aU);
M(i) = -M1U+R1U*x(i)-(WU*(x(i)-aU)^2)/2;
elseif x(i) >= (aU+dU); % Second portion of the beam, aU+dU < x < L
V(i) = -R2U;
M(i) = -M2U+R2U*(LU-x(i));
end
end
x1 = aU+R1U/WU;
Mmax = -M1U+(R1U*cgU)+(WU*(cgU-aU)^2)/2;

% Displaying the Reacctions for this Case


disp(' ');disp (['Left Support Reaction' ' = ' num2str(R1U) ' ' 'kN'])
disp(' ');disp (['Left Support Moment' ' = ' num2str(M1U) ' ' 'kN-m'])
disp(' ');disp (['Right Support Reaction' ' = ' num2str(R2U) ' ' 'kN'])
disp(' ');disp (['Right Support Moment' ' = ' num2str(M2U) ' ' 'kN-m'])
disp(' ');disp (['Mmax' ' = ' num2str(Mmax) ' ' 'kNm'])

elseif LoadType == 3; %Code for VDL Calculations


for i = 1:n+1
if x(i) <= aV; % First portion of the beam, 0 < x <= aV
V(i) = R1V;
M(i) = -M1V+R1V*x(i);
elseif aV < x(i) && x(i)< bV; % Second portion of the beam, aV < x <
bV
V(i) = R1V-(WV*(x(i)-aV)^2)/(2*dV);
M(i) = -M1V+R1V*x(i)-(WV*(x(i)-aV)^3)/(6*cV);
elseif x(i) >= bV; % Second portion of the beam, bV < x < L
V(i) = -R2V;
M(i) = -M2V+R2V*(LV-x(i));
end
end
x1 = aV+cV*(((2*R1V)/(WV*cV))^0.5);
Mmax = -M1V+R1V*(aV+(2/3)*(2*R1V/(WV*cV))^0.5);

% Displaying the Reacctions for this Case


disp(' ');disp (['Left Support Reaction' ' = ' num2str(R1V) ' ' 'kN'])
disp(' ');disp (['Left Support Moment' ' = ' num2str(M1V) ' ' 'kN-m'])
disp(' ');disp (['Right Support Reaction' ' = ' num2str(R2V) ' ' 'kN'])
disp(' ');disp (['Right Support Moment' ' = ' num2str(M2V) ' ' 'kN-m'])
disp(' ');disp (['Mmax' ' = ' num2str(Mmax) ' ' 'kNm'])

elseif LoadType == 4; %Code for Combined Load Calculations


for i = 1:n+1
if x(i) < aP , x(i) < aU , x(i) < aV
V(i) = R1P + R1U + R1V;
M(i) = (-M1P+R1P*x(i))+(-M1U+R1U*x(i))+ (-M1V+R1V*x(i));

elseif x(i) < aP , x(i) < aU , aV < x(i) && x(i)< bV;
V(i) = R1P + R1U + (R1V-(WV*(x(i)-aV)^2)/(2*dV));
M(i) = (-M1P+R1P*x(i))+(-M1U+R1U*x(i))+ (-M1V+R1V*x(i)-(WV*(x(i)-
aV)^3)/(6*cV));

elseif x(i) < aP , x(i) < aU , x(i) >= bV;


V(i) = R1P + R1U + (-R2V);
M(i) = (-M1P+R1P*x(i))+(-M1U+R1U*x(i))+ (-M2V+R2V*(LV-x(i)));

elseif x(i) < aP , aU <= x(i) && x(i)< aU+dU , x(i) < aV;
V(i) = R1P + (R1U-WU*(x(i)-aU)) + R1V;
M(i) = (-M1P+R1P*x(i))+(-M1U+R1U*x(i)-(WU*(x(i)-aU)^2)/2)+ (-
M1V+R1V*x(i));

elseif x(i) < aP , aU <= x(i) && x(i)< aU+dU , aV < x(i) && x(i)< bV;
V(i) = R1P + (R1U-WU*(x(i)-aU)) + (R1V-(WV*(x(i)-aV)^2)/(2*dV));
M(i) = (-M1P+R1P*x(i))+(-M1U+R1U*x(i)-(WU*(x(i)-aU)^2)/2)+ (-
M1V+R1V*x(i)-(WV*(x(i)-aV)^3)/(6*cV));

elseif x(i) < aP , aU <= x(i) && x(i)< aU+dU , x(i) >= bV;
V(i) = R1P + (R1U-WU*(x(i)-aU)) + (-R2V);
M(i) = (-M1P+R1P*x(i))+(-M1U+R1U*x(i)-(WU*(x(i)-aU)^2)/2)+ (-
M2V+R2V*(LV-x(i)));
elseif x(i) < aP , x(i) >= (aU+dU) , x(i) < aV;
V(i) = R1P + (-R2U) + R1V;
M(i) = (-M1P+R1P*x(i))+(-M2U+R2U*(LU-x(i)))+ (-M1V+R1V*x(i));

elseif x(i) < aP , x(i) >= (aU+dU) , aV < x(i) && x(i)< bV;
V(i) = R1P + (-R2U) + (R1V-(WV*(x(i)-aV)^2)/(2*dV));
M(i) = (-M1P+R1P*x(i))+(-M2U+R2U*(LU-x(i)))+ (-M1V+R1V*x(i)-
(WV*(x(i)-aV)^3)/(6*cV));

elseif x(i) < aP , x(i) >= (aU+dU) , x(i) >= bV;


V(i) = R1P + (-R2U) + (-R2V);
M(i) = (-M1P+R1P*x(i))+(-M2U+R2U*(LU-x(i)))+ (-M2V+R2V*(LV-x(i)));

elseif x(i) >= aP , x(i) < aU , x(i) < aV;


V(i) = (R1P-WP) + R1U + R1V;
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M1U+R1U*x(i))+ (-
M1V+R1V*x(i));

elseif x(i) >= aP , x(i) < aU , aV < x(i) && x(i)< bV;
V(i) = (R1P-WP) + R1U + (R1V-(WV*(x(i)-aV)^2)/(2*dV));
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M1U+R1U*x(i))+ (-
M1V+R1V*x(i)-(WV*(x(i)-aV)^3)/(6*cV));

elseif x(i) >= aP , x(i) < aU , x(i) >= bV;


V(i) = (R1P-WP) + R1U + (-R2V);
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M1U+R1U*x(i))+ (-
M2V+R2V*(LV-x(i)));

elseif x(i) >= aP , aU <= x(i) && x(i)< aU+dU , x(i) < aV;
V(i) = (R1P-WP) + (R1U-WU*(x(i)-aU)) + R1V;
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M1U+R1U*x(i)-(WU*(x(i)-
aU)^2)/2)+ (-M1V+R1V*x(i));

elseif x(i) >= aP , aU <= x(i) && x(i)< aU+dU , aV < x(i) && x(i)<
bV;
V(i) = (R1P-WP) + (R1U-WU*(x(i)-aU)) + (R1V-(WV*(x(i)-
aV)^2)/(2*dV));
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M1U+R1U*x(i)-(WU*(x(i)-
aU)^2)/2)+ (-M1V+R1V*x(i)-(WV*(x(i)-aV)^3)/(6*cV));

elseif x(i) >= aP , aU <= x(i) && x(i)< aU+dU , x(i) >= bV;
V(i) = (R1P-WP) + (R1U-WU*(x(i)-aU)) + (-R2V);
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M1U+R1U*x(i)-(WU*(x(i)-
aU)^2)/2)+ (-M2V+R2V*(LV-x(i)));

elseif x(i) >= aP , x(i) >= (aU+dU) , x(i) < aV;


V(i) = (R1P-WP) + (-R2U) + R1V;
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M2U+R2U*(LU-x(i)))+ (-
M1V+R1V*x(i));

elseif x(i) >= aP , x(i) >= (aU+dU) , aV < x(i) && x(i)< bV;
V(i) = (R1P-WP) + (-R2U) + (R1V-(WV*(x(i)-aV)^2)/(2*dV));
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M2U+R2U*(LU-x(i)))+ (-
M1V+R1V*x(i)-(WV*(x(i)-aV)^3)/(6*cV));

elseif x(i) >= aP , x(i) >= (aU+dU) , x(i) >= bV;


V(i) = (R1P-WP) + (-R2U) + (-R2V);
M(i) = (-M1P+R1P*x(i)-WP*(x(i)-aP))+(-M2U+R2U*(LU-x(i)))+ (-
M2V+R2V*(LV-x(i)));
end
end

% Displaying the Reacctions for this Case


disp(' ');disp (['Left Support Reaction' ' = ' num2str(R1) ' ' 'kN'])
disp(' ');disp (['Left Support Moment' ' = ' num2str(M1) ' ' 'kN-m'])
disp(' ');disp (['Right Support Reaction' ' = ' num2str(R2) ' ' 'kN'])
disp(' ');disp (['Right Support Moment' ' = ' num2str(M2) ' ' 'kN-m'])
end

% code for Plotting of SFD and BMD


figure

subplot(2,1,1);
plot(x, V, 'r','linewidth',1.5);
grid

line([x(1) x(end)],[0 0],'Color','k');


line([0 0],[0 V(1)],'Color','r','linewidth',1.5);
line([x(end) x(end)],[0 V(end)],'Color','r','linewidth',1.5);
title('Shear Force Diagram','fontsize',16)

if LoadType ==1

text(aP/2,V(1),num2str(V(1)),'HorizontalAlignment','center','FontWeight','bol
d','fontsize',16)
text((LP-
cP/2),V(end),num2str(V(end)),'HorizontalAlignment','center','FontWeight','bol
d','fontsize',16)
elseif LoadType ==2

text(aU/2,V(1),num2str(V(1)),'HorizontalAlignment','center','FontWeight','bol
d','fontsize',16)
text((LU-
cU/2),V(end),num2str(V(end)),'HorizontalAlignment','center','FontWeight','bol
d','fontsize',16)
elseif LoadType==3

text(aV/2,V(1),num2str(V(1)),'HorizontalAlignment','center','FontWeight','bol
d','fontsize',16)
text((LV-
cV/2),V(end),num2str(V(end)),'HorizontalAlignment','center','FontWeight','bol
d','fontsize',16)
end

axis off
subplot(2,1,2);
plot(x, M, 'r','linewidth',1.5);
grid

line([x(1) x(end)],[0 0],'Color','k');


line([x1 x1],[0 Mmax],'LineStyle','--','Color','b');
title('Bending Moment Diagram','fontsize',16)

if LoadType ==1
text(x1+1/LP,Mmax/2,num2str(roundn(Mmax,-
2)),'HorizontalAlignment','center','FontWeight','bold','fontsize',16)
elseif LoadType ==2
text(x1+1/LU,Mmax/2,num2str(roundn(Mmax,-
2)),'HorizontalAlignment','center','FontWeight','bold','fontsize',16)
elseif LoadType==3
text(x1+1/LV,Mmax/2,num2str(roundn(Mmax,-
2)),'HorizontalAlignment','center','FontWeight','bold','fontsize',16)
end

text(x1,0,[num2str(roundn(x1,-2)) '
m'],'HorizontalAlignment','center','FontWeight','bold','fontsize',16)

axis off

You might also like