Sie sind auf Seite 1von 15

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);

POINT LOAD FUNCTION

%FUNCTION DEFINITION
%PURPOSE: To bending moment, shear force and deflection values of a point load
%l = length of the beam
%E = Youngus modulus of the beam
%I = Moment of inertia
%locn = Location of point load from the left end
%value = Point load magnitude
%BM = Bending moment array
%SF = Shear force array
%Y = Deflection array
function[BM,SF,Y]=pointload(l,E,I,locn,value)
l=l;
a=locn;
w=value;
E=E;
I=I;
Ra= w;
Ma= w*a;
x=0:0.01:l;
% EQUATIONS USED:
%
When (x<= a)
%
SF= Ra
%
BM= (Ra * x Ma)
%
Y = ((Ra * x3 )/6 - ( Ma * x2) /2)/(E*I)
%
When (x>a)
%
SF = 0
%
BM= 0
%
Y= (Y((a*100)+1)+(Y((a*100)+1)*(x-a)/a))

for

i=1:length(x);
if (x(i) <= a)
SF(i)= Ra/(E*I);
BM(i)= (Ra * x(i) - Ma)/(E*I);
Y(i) = (Ra * x(i)^3 /6 - ( Ma * x(i)^2 /2))/(E*I);

else
SF(i) = 0;
BM(i) = 0;
Y(i) = (Y((a*100)+1)+(Y((a*100)+1)*(x(i)-a)/a))
end
end
end

UNIFORMLY DISTRIBUTED LOAD FUNCTION

%FUNCTION DEFINITION
%Purpose : To draw the bending moment Shear force diagram and deflection
diagram for a udl
%l = length of the beam
%E = Youngus modulus of the beam
%I = Moment of inertia
%spoint= start point of udl from left end
%length= Length of udl
%Value = Magnitude of uvl at start point
%BM = Bending moment array
%SF = Shear force array
%Y = Deflection array
function [BM SF Y]=UDL(l,E,I,spoint,lengthh,value)
l=l;
a=spoint;
b=(spoint+lengthh);
w=value;
E=E;
I=I;
Ra= w*(b-a);
Ma= w*(b-a) * (a + (b-a)/2);
x=0:0.01:l;
%EQUATIONS USED
%
when(x <= a)
%
SF = Ra
%
BM = Ra*x - Ma
%
Y = ((Ra* x3)/6 -( Ma*x2)/2))/(E*I)
%
%
when(x >= a) && (x <= b)
%
SF = Ra-w*( x-a)
%
BM = Ra*x-Ma-(w*(x-a)2)/2
%
Y =((Ra*x3 )/6-((Ma* x2)/2 )-(w*(x - a)4)/24)/(E*I))
%
%
when(x =l)
%
SF = 0
%
BM = 0
%
Y = (Y((b*100)+1)+(Y((b*100)+1)*(x-b)/b))
for

i=1:length(x);
if (x(i) <= a)
SF(i)= Ra/(E*I);
BM(i)= (Ra * x(i) - Ma)/(E*I);
Y(i) = (Ra * x(i)^3 /6 - ( Ma * x(i)^2 /2))/(E*I);

elseif (x(i) >= a) && (x(i) <= b)


SF(i)=(Ra
- w *( x(i) -a))/(E*I) ;
BM(i)=(Ra * x(i) - Ma - w*( x(i) -a)*(x(i) -a)/2)/(E*I);
Y(i) = ((Ra * x(i)^3 )/6 - ((Ma * x(i)^2) /2 )-( w *( x(i) - a)^4)/24)/
(E*I) ;%- (x(i)*w* a^3 )/6 + (a^4 * w)/24
else
SF(i) = 0;

BM(i) = 0;
Y(i) = (Y((b*100)+1)+(Y((b*100)+1)*(x(i)-b)/b))
end
end
end

UNIFORM VARYING LOAD FUNCTION


1. MAXIMUM LOAD AT STARTING POINT
%FUNCTION DEFINITION
%Purpose : To draw the bending moment Shear force diagram and deflection
diagram for a uvl
%l = length of the beam
%E = Youngus modulus of the beam
%I = Moment of inertia
%spoint= start point of uvl from left end
%length= Length of uvl
%Value = Magnitude of uvl at start point
%BM = Bending moment array
%SF = Shear force array
%Y = Deflection array

function [BM,SF,Y]=UVLMAXMIN(l,E,I,spoint,lengthh,value)
l=l;
a=lengthh;
w=value;
E=E;
I=I;
Ra= w * a/2;
Ma= w*a^2 /3;
x=0:0.01:l;
%EQUATIONS USED
%

when (x <= a)

%
)

SF=-((- w*a/2 + (w/(a*2)) * (2*x*a - 3*x2)+(2*x*w-(w/a)*(2*x*a-3*x2))/3)

BM= -((w*a2/6 - w*a*x/2 + x*w*(a-x)*x/(a*2)+x2*(w-(w/a)*(a-x))/3))

%
Y = -(w*a2*x2/12 -( w*a*x3)/12) + (w/2*a)*(a*(x4/12)-x5/20)+1/3*( w*x4/12
-(w/a*(x4/12*a-x5 /20))/(E*I)
%
%

when (x <= l)
SF = 0;

%
%

BM = 0;
Y = (Y((a*100)+1)+(Y((a*100)+1)*(x-a)/a))

for

i=1:length(x);
if (x(i) <= a)

SF(i)=-((- w*a/2 + (w/(a*2) ) * (2*x(i)*a - 3*x(i)^2)


(w/a)*(2*x(i)*a - 3 * x(i)^2))/3) );

(2*x(i)*w -

BM(i)= -((w*a^2/6 - w*a*x(i)/2 + x(i)*w*(a-x(i))*x(i) /(a*2)


* (w - (w/a)*(a-x(i)))/3) );

x(i)^2

Y(i) = -(w* a^2 * x(i)^2 /12 -( w*a*x(i)^3 /12) + (w/2*a) * (a*(x(i)^4 /


12) - x(i)^5 / 20 ) + 1/3 * ( w*x(i)^4 /12 -(w/a * (x(i)^4 /12 *a - x(i)^5 /20
)))
) /(E*I) ;
else
SF(i) = 0;
BM(i) = 0;
Y(i) = (Y((a*100)+1)+(Y((a*100)+1)*(x(i)-a)/a))
end
end
end

UNIFORMLY VARYING LOAD


2. MAXIMUM LOAD AT ENDING POINT
%FUNCTION DEFINITION
%Purpose: To draw the bmd, sfd, deflection diagram of a uvl when the
%minimum load is at the beginning
%l = length of the beam
%E = Youngus modulus of the beam
%I = Moment of inertia
%spoint= start point of uvl from left end
%length= Length of uvl
%Value = Magnitude of uvl at start point
%BM = Bending moment array
%SF = Shear force array
%Y = Deflection array
%starting point is 0 value

function [BM,SF,Y]=UVLMINMAX(l,E,I,spoint,lengthh,value)

l=l;
a=lengthh;
w=value;
E=E;
I=I;
% 03*03
Ra= w * a/2;
Ma= w*a^2 /3;
x=0:0.01:l;
% EQUATIONS USED
% When (x <= a)
%
SF(i) = (Ra- ( (x)2 * (w/(2*a) ) ))
%
BM(i) = (Ra * x-(w * x3 )/(6 * a) - Ma)
%
Y(i) =( (Ra*x3 )/6 - w*x4 /(120*a)-Ma*x2/2 )/(E*I)
% When(x>a)
%
SF = 0
%
BM = 0
%
Y = (Y((a*100)+1)+(Y((a*100)+1)*(x-a)/a))
for

i=1:length(x);
if (x(i) <= a)
SF(i) = (Ra - ( (x(i))^2 * (w/(2*a) ) ))/(E*I);

BM(i) = (Ra * x(i)-(w * x(i)^3 )/(6 * a) - Ma)/(E*I);


Y(i) =( Ra*x(i)^3 /6 - w*x(i)^4 /(120*a) -Ma*x(i)^2/2 )/(E*I);
else
SF(i) = 0;
BM(i) = 0;
Y(i) = (Y((a*100)+1)+(Y((a*100)+1)*(x(i)-a)/a));
end
end
end

MOMENT
%FUNCTION DEFINITION
% Purpose : To get the Shear force diagram, Bending moment diagram,
%Deflection diagram of a beam subjected to a concentrated moment.
%l = length of the beam
%E = Youngus modulus of the beam
%I = Moment of inertia
%locn = Location of point load from the left end

%value = Point load magnitude


%BM = Bending moment array
%SF = Shear force array
%Y = Deflection array
function[BM,SF,Y]=moment(l,E,I,locn,value)
l=l;
a=locn;
w=value;
E=E;
I=I;
Ra= 0;
Ma=l ;
x=0:0.01:l;
%EQUATIONS USED
% When (x<= a)
%
SF = 0;
%
BM =- Ma
%
Y =-((Ma * x2 )/2)/(E*I)
% When (x>a)
%
SF = 0
%
BM = 0
%
Y = (Y((a*100)+1)+(Y((a*100)+1)*(x-a)/a))
for

i=1:length(x);
if (x(i) <= a)
SF(i) = 0;
BM(i) =- Ma/(E*I);
Y(i) =-((Ma * x(i)^2 )/2)/(E*I);
else

end

SF(i) = 0;
BM(i) = 0;
Y(i) = (Y((a*100)+1)+(Y((a*100)+1)*(x(i)-a)/a));

end
end

BENDING STRESS
%Definition
%Purpose : To plot the Bending Stress across the cross section
%Function to calculate the Bending stress
%b=width of the beam
%d=depth of the beam
%M=max bending moment
function [x]=bstress(b,d,M)
b=b;
d=d;

I = b*d^3 /12;
M=M;
i=0;
%EQUATIONS USED
%M/I=f/y
%f=(M*y/I)
for y=-d/2:0.01:d/2
i=i+1;
if((i==1))
f(i)=0;
elseif ((y==d/2))
f(i)=0;
else
f(i)=M*y/I;
end

end
y=-d/2:0.01:d/2
x=[0 0]
ey=[-d/2 d/2]
plot(x,ey)
hold on
plot (f,y)
title('Bending Stress');
end

SHEAR STRESS
%Purpose : to plot shear stress across the cross section
%b=width of the beam
%d=depth of the beam
%maxsf=max shear force
function [x]=sstress(b,d,maxsf)
b=b;
d=d;
x=0;
x2=[0 0];
y2=[-150 150];
a=b*d;
v=maxsf;
I=(b*d^3)/12;
d1=-d/2:0.1:d/2;sss=zeros(length(d1),1);A=(0);y=(0);
%
%
%
%

EQUATIONS USED
A=(b*((d/2)-d1))
y=(((d/2)-d1)/2)+d1
sss=(v*A)*(y)/(I*b)

for MI=1:1:length(d1)

A(MI)=(b*((d/2)-d1(MI)));
y(MI)=(((d/2)-d1(MI))/2)+d1(MI);
sss(MI)=(v*A(MI))*(y(MI))/(I*b);

end
plot(sss,d1,x2,y2)
hold on
title('Shear stress')

SOLUTION
User inputs
Enter
Enter
Enter
Enter

the
the
the
the

length of the beam(m)= 10


width of the beam(m)= .23
depth of the beam(m)= .3
modulus of elasticity(E)(N/m^2)= 2000000

Enter types of loads and number of loads in each category


Enter Number of Point Loads= 1
Enter Number of UDL= 1
WARNING: Enter only one UVL !!!!!
Enter Number of UVL= 1
Enter Number of Moments= 1
Enter point load details of load no 1
Enter Point Load location from left end= 9
Enter Point Load value= 10
Enter
Enter
Enter
Enter

UDL
UDL
UDL
UDL

details of load no 1
Start point from left end= 6
length= 2
Value= 18

Enter UVL details of load no 1


1.UVL start position is max
2.UVL end position is max
Enter max position= 2

Enter UVL length= 3


Enter UVL Value= 20
Enter Concentrated Moment details of load no 1
Enter Moment location= 4
Enter Moment value= 20

Obtained result

Das könnte Ihnen auch gefallen