You are on page 1of 5

MAIN PROGRAM

clc
clear all
%To get basic inputs from the user "length"; "Width"; "Depth" of Beam c/s
%and "Youngs Modulus" of beam cross section
l=input('Enter
B=input('Enter
D=input('Enter
E=input('Enter
I=(B*D^3)/12;

the
the
the
the

length of the beam(m)= ');


width of the beam(m)= ');
depth of the beam(m)= ');
modulus of elasticity(E)(N/m^2)= ');

%Get input of number of loads under each type of load


fprintf ('\n\nEnter types of loads and number of loads in each category\n');
npl=input('\nEnter Number of Point Loads= ');
nudl=input('\nEnter Number of UDL= ');
fprintf('\n WARNING: Enter only one UVL !!!!!');
nuvl=input('\nEnter Number of UVL= ');
nm=input('\nEnter Number of Moments= ');
%Getting input of POINT LOAD details
%every column of "pl" matrix maps to a point load
%first row of "pl" matrix corresponds to the location of point load in the
%beam
for i=1:1:npl
fprintf('\n \nEnter point load details of load no %d \n', i);
pl(1,i)=input('Enter Point Load location from left end= ');
pl(2,i)=input('Enter Point Load value= ');
end

%Getting input of UNIFORMLY DISTRIBUTED LOAD details


%every column of "udl" matrix maps to a udl
%first row of "udl" matrix corresponds to the start point of the udl
%second row of "udl" matrix corresponds to the length of the udl
%third row of "udl" matrix corresponds to the value of the udl
for i=1:1:nudl
fprintf('\n \nEnter UDL details of load no %d \n', i);
udl(1,i)=input('Enter UDL Start point from left end= ');
udl(2,i)=input('Enter UDL length= ');
udl(3,i)=input('Enter UDL Value= ');
end

%Getting input of UNIFORMLY VARYING LOAD details


%every column of "uvl" matrix maps to a uvl
%first row of "uvl" matrix corresponds to the type of uvl
%second row of "uvl" matrix corresponds to the length of the uvl
%third row of "uvl" matrix corresponds to the value of the uvl
for i=1:1:nuvl
fprintf('\n \nEnter UVL details of load no %d \n 1.UVL start position is
max \n 2.UVL end position is max\n', i);
uvl(1,i)=input('Enter max position= ');
uvl(2,i)=input('Enter UVL length= ');
uvl(3,i)=input('Enter UVL Value= ');
end
%moment details
for i=1:1:nm
fprintf('\n \nEnter Concentrated Moment details of load no %d \n', i);
mo(1,i)=input('Enter Moment location= ');
mo(2,i)=input('Enter Moment value= ');
end
%superposition of loads
%point load
for i=1:1:npl
if(i==1)
[bmp,sfp,dfp]=pointload(l,E,I,pl(1,i),pl(2,i));
else
[bm1p,sf1p,df1p]=pointload(l,E,I,pl(1,i),pl(2,i));
bmp=bmp+bm1p;
sfp=sfp+sf1p;
dfp=dfp+df1p;
end
end
%Udl
for i=1:1:nudl
if(i==1)
[bmu,sfu,dfu]=UDL(l,E,I,udl(1,i),udl(2,i),udl(3,i));
else
[bm1u,sf1u,df1u]=UDL(l,E,I,udl(1,i),udl(2,i),udl(3,i));
bmu=bmu+bm1u;
sfu=sfu+sf1u;

end

dfu=dfu+df1u;

end
%Uvl
for i=1:1:nuvl
if(i==1)
if(uvl(1,i)==1)
[bmv,sfv,dfv]=UVLMAXMIN(l,E,I,0,uvl(2,i),uvl(3,i));
else
[bmv,sfv,dfv]=UVLMINMAX(l,E,I,0,uvl(2,i),uvl(3,i));
end
else
if(uvl(1,i)==1)
[bm1v,sf1v,df1v]=UVLMAXMIN(l,E,I,0,uvl(2,i),uvl(3,i));
bmv=bmv+bm1v;
sfv=sfv+sf1v;
dfv=dfv+df1v;
else
[bm1v,sf1v,df1v]=UVLMINMAX(l,E,I,0,uvl(2,i),uvl(3,i));
bmv=bmv+bm1v;
sfv=sfv+sf1v;
dfv=dfv+df1v;
end
end
end
%Moment calculation
for i=1:1:nm
if(i==1)
[bmm,sfm,dfm]=moment(l,E,I,mo(1,i),mo(2,i));
else
[bm1m,sf1m,df1m]=moment(l,E,I,mo(1,i),mo(2,i));
bmm=bmm+bm1m;
sfm=sfm+sf1m;
dfm=dfm+df1m;
end
end
%adding different cases BM SF and DF
if((npl==0)&&(nudl==0))
BM=bmv+bmm;
SF=sfv+sfm;
DF=dfv+dfm;
elseif((nudl==0) && (nuvl==0))
BM=bmp+bmm;
SF=sfp+sfm;
DF=dfp+dfm;
elseif((npl==0) && (nuvl==0))
BM=bmu+bmm;
SF=sfu+sfm;
DF=dfu+dfm;
elseif((npl==0) && (nm==0)
BM=bmu+bmv;
SF=sfu+sfv;

DF=dfu+dfv;
elseif((nudl==0) && (nm==0)
BM=bmp+bmv;
SF=sfp+sfv;
DF=dfp+dfv;
elseif((nuvl==0) && (nm==0)
BM=bmp+bmu;
SF=sfp+sfu;
DF=dfp+dfu;
elseif((npl==0))
BM=bmu+bmv+bmm;
SF=sfu+sfv+sfm;
DF=dfu+dfv+dfm;
elseif((nudl==0))
BM=bmp+bmv+bmm;
SF=sfp+sfv+sfm;
DF=dfp+dfv+dfm;
elseif((nuvl==0))
BM=bmp+bmu+bmm;
SF=sfp+sfu+sfm;
DF=dfp+dfu+dfm;
elseif((nm==0))
BM=bmp+bmu+bmv;
SF=sfp+sfu+sfv;
DF=dfp+dfu+dfv;
else
BM=bmp+bmv+bmu+bmm;
SF=sfp+sfv+sfu+sfm;
DF=dfp+dfv+dfu+dfm;
end
%storing max moment,shear force and deflection
maxM=max(abs(BM));
maxF=max(abs(SF));
maxy=max(abs(DF));
%storing address of max moment,shear force and deflection
for i=1:length(BM)
if(BM(i)==max(abs(BM)))
Mmax=i;
end
if(SF(i)==max(abs(SF)))
Fmax=i;
end
if(DF(i)==max(abs(DF)))
Ymax=i;
end
end

xaxis=0:0.01:l;
% plotting of beams
ex=[0 l]
y=[0 0]
figure(1);
subplot(4,1,1)

plot(ex,y,'k','linewidth',5);
hold on
for i=1:1:npl
[x]=ptld(pl(1,i));
end
for i=1:1:nudl
[x]=udlpt(udl(1,i),udl(2,i));
end
for i=1:1:nuvl
if(uvl(1,i)==1)
[x]=uvlpt(0,uvl(2,i));
else
[x]=uvlpti(0,uvl(2,i));
end
end
for i=1:1:nm
[x]=mplot(mo(1,i));
end
exx=[0 0];
eyy=[-0.3 0.3];
plot(exx,eyy,'k','linewidth',30)
xlim([0 l]);
title('Beam Representation');
hold off
subplot(4,1,2)
plot(ex,y);hold on
plot(xaxis,BM,'r','linewidth',2)
%xlim([-1 (l+1)]);
title('Bending Moment');
hold off
subplot(4,1,3)
plot(ex,y);hold on
plot(xaxis,SF,'g','linewidth',2)
%xlim([-1 (l+1)]);
title('Shear Force');hold off
subplot(4,1,4)
plot(ex,y);hold on;
plot(xaxis,DF,'b','linewidth',2)
%xlim([-1 (l+1)]);
title('Deflection');hold off
figure(2)
B=1000*B;
D=1000*D;
subplot(1,2,1)
[x]=sstress(B,D,maxF);
subplot(1,2,2)
[x]=bstress(B,D,maxF);

You might also like