Vous êtes sur la page 1sur 57

%-------------------------------------------------------------------------------

-------------------
% Stephen Smith
% E MCH 407, Spring 2010, Final Project
%-------------------------------------------------------------------------------
-------------------

clear
clc

% Collect input about the beam from the user


length=input('Enter the length of the beam : ');
pload=input('Enter the value of the point load in either lb or N : ');
if pload==0
plocation=0;
else
plocation=input('Enter the location of the point load from the left end of the b
eam : ');
end
distributedload=input('Enter the value of the distributed load in either lb/ft o
r N/m : ');
if distributedload==0
startlocation=0;
endlocation=0;
else
startlocation=input('Enter the location from the left end of the beam where the
distributed load starts : ');
endlocation=input('Enter the location from the left end of the beam where the di
stributed load ends : ');
end
moment=input('Enter the value of the moment in either lb-ft or N-m : ');
if moment==0
signofmoment=1;
mlocation=0;
else
mlocation=input('Enter the location of the moment from the left end of the beam
: ');
signofmoment=input('Enter a 1 if the moment is counterclockwise and -1 if the mo
ment is clockwise : ');
end
support1=0; % A simp
lplification because I am only
support2=length; % consid
ering a simply support beam

% Determine the reaction forces in the beam


if signofmoment==1
A=[1 1;support1 support2]; % Create
s the A matrix to solve
% the fo
rce and moment system
% of equ
ations for beam. Row 1
% is for
forces and row 2 is for
% moment
s.
b=[pload+distributedload*(endlocation-startlocation);(startlocation... % Create
s the B matrix. Row 1
+(endlocation-startlocation)/2)*((endlocation-startlocation)... % is for
forces and row 2 is for
*distributedload)+pload*plocation-moment]; % moment
s.
elseif signofmoment==-1
A=[1 1;support1 support2]; % Create
s the A matrix to solve
% the fo
rce and moment system
% of equ
ations for beam. Row 1
% is for
forces and row 2 is for
% moment
s.
b=[pload+distributedload*(endlocation-startlocation);(startlocation... % Create
s the B matrix. Row 1
+(endlocation-startlocation)/2)*((endlocation-startlocation)... % is for
forces and row 2 is for
*distributedload)+pload*plocation+moment]; % moment
s.
end

xinit=[0;0]; % Initia
l guess for the solution
tola=1e-5; % Allowa
ble tolerance
% I will
now use a jacobi
% iterat
ive method to solve the
% system
of equations
x=xinit; % Sets t
he initial guess to the x vector.
[m,n]=size(A); % Determ
ines the size of the matrix enterered.
for i=1:n
for j=1:n
if i==j
E(i,j)=0;
else % Rewrit
es Ax=b in the
E(i,j)=-A(i,j)/A(i,i); % form x
(j)=F+Ex.
end
F(i)=b(i)/A(i,i);
end
end
iter=1; % Counte
r for number of iterations.
while iter < 100 % Ensure
s the program will stop.
xold=x; % Introd
uces a variable to store the
% previo
us iteration's values.
for i=1:n
sum=0; % Resets
the value of 'sum' for each iteration.
for j=1:n
sum=sum+E(i,j)*x(j); % Calcul
ates the value of x(i).
end
x(i)=sum+F(i); % Assign
s the previously calculated value
% to x(i
).
end
for i=1:n
diff(i)=abs((abs(x(i))-abs(xold(i)))/abs(x(i))); % Calcul
ates a measure of convergence.
end
tol=max(diff); % Determ
ines the highest value of the
% measur
e of convergence.
if tol <= tola % Determ
ines if the measure of convergence
iter=101; % is bel
ow the user inputed tolerance.
else
iter=iter+1;
end
end

% use the reaction forces to create the shear and moment diagrams
if distributedload==0 && moment==0
% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
xx=support1:plocation; % Create
s and plots the line from
y=0*xx+x(1); % the fi
rst support to the load
plot(xx,y)
q=-x(2):x(1); % Create
s and plots the line for
p=0*q+plocation; % load o
n the beam
plot(p,q)
t=plocation:support2; % Create
s and plots the line from
z=0*t-x(2); % the lo
ad to the second support
plot(t,z)

% The equations for the moment diagram


m1=(((x(1)*plocation)-0)/plocation)*xx+0; % Create
s and plots the line from
plot(xx,m1,'r') % the fi
rst support to the load
slope=((0-(x(1)*plocation))/(length-plocation)); % Determ
ines the slope for the
% next p
art of the graph
m2=slope*t+abs(slope)*plocation+x(1)*plocation; % Create
s and plots the line from
plot(t,m2,'r') % the se
cond support to the load
hold off;

elseif pload==0 && moment==0


% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)

xx=0:startlocation; % Create
s and plots the line from
y=0*xx+x(1); % the fi
rst support to the distributed load
plot(xx,y)
p=startlocation:endlocation; % Create
s and plots the line for
slope=((-x(2)-x(1))/(endlocation-startlocation)); % the di
stributed load
q=slope*p+(x(1)+abs(slope)*(startlocation-support1));
plot(p,q)
t=endlocation:support2; % Create
s and plots the line from
z=0*t-x(2); % the di
stributed load to the second support
plot(t,z)
% The equations for the moment diagram
m1=(((x(1)*startlocation)-0)/(startlocation-support1))*xx+0; % Create
s and plots the line from
plot(xx,m1,'r') % the fi
rst support to the load
slope2=(0-(x(2)*(support2-endlocation)))/(support2-endlocation); % Create
s and plots the line from the end
m2=slope2*t+(x(2)*(support2-endlocation)+abs(slope2)*endlocation); % of the
distributed load to the second support
plot(t,m2,'r')
u=startlocation:endlocation; % Create
s and plots the parabola from the
v=x(1)*u-(distributedload/2)*(u-startlocation).^2; % start
of the distributed load to the end
plot(u,v,'r')
hold off;

elseif pload==0 && distributedload==0


% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=0:-x(2); % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
xx=support1:support2; % Create
s and plots the line from the
y=0*xx+x(1); % the fi
rst support to the second support
plot(xx,y)

if signofmoment==1
% The equations for the moment diagram
slope1=(moment/2-0)/(mlocation-support1); % Create
s and plots the line from the
t=support1:mlocation; % first
support to the moment
z=slope1*t;
plot(t,z,'r')
slope2=(0+moment/2)/(support2-mlocation); % Create
s and plots the line from the
p=mlocation:support2; % moment
to the second support
q=slope2*p-(moment/2+abs(slope2)*mlocation);
plot(p,q,'r')
m=-moment/2:moment/2; % Create
s and plots the line for
f=0*m+mlocation; % the mo
ment
plot(f,m,'r')
hold off;

elseif signofmoment==-1
% The equations for the moment diagram
slope1=(-moment/2-0)/(mlocation-support1); % Create
s and plots the line from the
t=support1:mlocation; % the fi
rst support to the moment
z=slope1*t;
plot(t,z,'r')
slope2=(0-moment/2)/(support2-mlocation); % Create
s and plots the line from the
p=mlocation:support2; % moment
to the second support
q=slope2*p+(moment/2+abs(slope2)*mlocation);
plot(p,q,'r')
m=-moment/2:moment/2; % Create
s and plots the line for
f=0*m+mlocation; % the mo
ment
plot(f,m,'r')
hold off;
end

elseif distributedload==0
% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
xx=support1:plocation; % Create
s and plots the line from
y=0*xx+x(1); % the fi
rst support to the point load
plot(xx,y)
q=-x(2):x(1); % Create
s and plots the line for
p=0*q+plocation; % the po
int load
plot(p,q)
t=plocation:support2; % Create
s and plots the line from
z=0*t-x(2); % the po
int load to the second support
plot(t,z)

if plocation>mlocation
if signofmoment==1
% The equations for the moment diagram
slope1=(x(1)*mlocation-0)/(mlocation-support1); % Create
s and plots the line from the
n=support1:mlocation; % first
support to the moment
b=slope1*n+0;
plot(n,b,'r')
yy=x(1)*mlocation-moment:x(1)*mlocation; % Create
s and plots the line for
m1=0*yy+mlocation; % the mo
ment
plot(m1,yy,'r')
tt=mlocation:plocation; % Create
s and plots the line from the
zz=slope1*tt+((x(1)*mlocation-moment)-slope1*mlocation); % moment
to the point load
plot(tt,zz,'r')
slope2=(0-(x(1)*plocation-moment))/(support2-plocation); % Create
s and plots the line from the
pp=plocation:support2; % point
load to the second support
qq=slope2*pp+((x(1)*plocation-moment)+abs(slope2)*plocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1
% The equations for the moment diagram
slope1=(x(1)*mlocation-0)/(mlocation-support1); % Create
s and plots the line from the
n=support1:mlocation; % first
support to the moment
b=slope1*n+0;
plot(n,b,'r')
yy=x(1)*mlocation:x(1)*mlocation+moment; % Create
s and plots the line for the moment
m1=0*yy+mlocation;
plot(m1,yy,'r')
tt=mlocation:plocation; % Create
s and plots the line from the moment
zz=slope1*tt+((x(1)*mlocation+moment)-slope1*mlocation); % to the
point load
plot(tt,zz,'r')
slope2=(0-(x(1)*plocation+moment))/(support2-plocation); % Create
s and plots the line from the
pp=plocation:support2; % point
load to the second support
qq=slope2*pp+((x(1)*plocation+moment)+abs(slope2)*plocation);
plot(pp,qq,'r')
hold off;
end

elseif mlocation>plocation
if signofmoment==1
% The equations for the moment diagram
slope1=(x(1)*plocation-0)/(plocation-support1); % Create
s and plots the line from the
n=support1:plocation; % first
support to the point load
b=slope1*n+0;
plot(n,b,'r')
slope2=((x(1)*plocation-x(2)*(mlocation-plocation))-x(1)... % Create
s and plots the line from the
*plocation)/(mlocation-plocation); % point
load to the moment
tt=plocation:mlocation;
zz=slope2*tt+(x(1)*plocation+abs(slope2)*plocation);
plot(tt,zz,'r')
yy=((x(1)*plocation-x(2)*(mlocation-plocation))-moment):(x(1)... % Create
s and plots the line for the moment
*plocation-x(2)*(mlocation-plocation));
m1=0*yy+mlocation;
plot(m1,yy,'r')
pp=mlocation:support2; % Create
s and plots the line from the moment
qq=slope2*pp+(((x(1)*plocation-x(2)*(mlocation-plocation))... % to the
second support
-moment)+abs(slope2)*mlocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1
% The equations for the moment diagram
slope1=(x(1)*plocation-0)/(plocation-support1); % Create
s and plots the line from the
n=support1:plocation; % first
support to the point load
b=slope1*n+0;
plot(n,b,'r')
slope2=((x(1)*plocation-x(2)*(mlocation-plocation))-x(1)... % Create
s and plots the line from the
*plocation)/(mlocation-plocation); % point
load to the distributed load
tt=plocation:mlocation;
zz=slope2*tt+(x(1)*plocation+abs(slope2)*plocation);
plot(tt,zz,'r')
yy=(x(1)*plocation-x(2)*(mlocation-plocation)):((x(1)... % Create
s and plots the line for the moment
*plocation-x(2)*(mlocation-plocation))+moment);
m1=0*yy+mlocation;
plot(m1,yy,'r')
pp=mlocation:support2; % Create
s and plots the line from the moment
qq=slope2*pp+(((x(1)*plocation-x(2)*(mlocation-plocation))... % to the
second support
+moment)+abs(slope2)*mlocation);
plot(pp,qq,'r')
hold off;
end
elseif mlocation==plocation
if signofmoment==1
% The equations for the moment diagram
slope1=(x(1)*plocation-0)/(plocation-support1); % Create
s and plots the line from the
n=support1:plocation; % first
support to the point load
b=slope1*n+0;
plot(n,b,'r')
yy=(x(1)*plocation-moment):x(1)*plocation; % Create
s and plots the line for the moment
m1=0*yy+plocation;
plot(m1,yy,'r')
slope2=(0-(x(1)*plocation-moment))/(support2-plocation); % Create
s and plots the line from the
tt=plocation:support2; % point
load to the second support
zz=slope2*tt+((x(1)*plocation-moment)+abs(slope2)*plocation);
plot(tt,zz,'r')
hold off;
elseif signofmoment==-1
% The equations for the moment diagram
slope1=(x(1)*plocation-0)/(plocation-support1); % Create
s and plots the line from the
n=support1:plocation; % first
support to the point load
b=slope1*n+0;
plot(n,b,'r')
yy=x(1)*plocation:(x(1)*plocation+moment); % Create
s and plots the line for the moment
m1=0*yy+plocation;
plot(m1,yy,'r')
slope2=(0-(x(1)*plocation+moment))/(support2-plocation); % Create
s and plots the line from the
tt=plocation:support2; % point
load to the second support
zz=slope2*tt+((x(1)*plocation+moment)+abs(slope2)*plocation);
plot(tt,zz,'r')
hold off;
end
end

elseif moment==0
if plocation<=startlocation
% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
u=support1:plocation; % Create
s and plots the line
v=0*u+x(1); % from t
he first support to the point load
plot(u,v)
y=(x(1)-pload):x(1); % Create
s and plots the line for
xx=0*y+plocation; % the po
int load
plot(xx,y)
p=plocation:startlocation; % Create
s and plots the line from the
q=0*p+(x(1)-pload); % point
load to the distributed load
plot(p,q)
slope=(-x(2)-(x(1)-pload))/(endlocation-startlocation); % Create
s and plots the line for the
t=startlocation:endlocation; % distri
buted load
z=slope*t+(x(1)-pload+abs(slope)*startlocation);
plot(t,z)
n=endlocation:support2; % Create
s and plots the line from the end
b=0*n-x(2); % of the
distributed load to the second support
plot(n,b)

% The equations for the moment diagram


slope1=(plocation*x(1)-0)/(plocation-support1); % Create
s and plots the line from the
uu=support1:plocation; % first
support to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=(((x(1)-pload)*(startlocation-plocation)+x(1)*plocation)... % Create
s and plots the line from the point
-x(1)*plocation)/(startlocation-plocation); % load t
o the distributed load
tt=plocation:startlocation;
zz=slope2*tt+(x(1)*plocation-abs(slope2)*plocation);
plot(tt,zz,'r')
c1=(x(1)-pload)*(startlocation-plocation)+x(1)*plocation; % Create
s variables to be used in solving
c2=(x(1)-pload)*(startlocation-plocation)+x(1)*plocation... % for th
e equation of the parabola
+.5*((x(1)-pload)/distributedload)*(x(1)-pload);
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
nn=endlocation:support2; % distri
buted load to the second support
mm=slope3*nn+(x(2)*(support2-endlocation)+abs(slope3)*endlocation);
plot(nn,mm,'r')
hold off;

elseif plocation>=endlocation
% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
u=support1:startlocation; % Create
s and plots the line
v=0*u+x(1); % from t
he first support to the distributed load
plot(u,v)
slope=((-x(2)+pload)-x(1))/(endlocation-startlocation); % Create
s and plots the line for
t=startlocation:endlocation; % the di
stributed load
z=slope*t+(x(1)+abs(slope)*startlocation);
plot(t,z)
n=endlocation:plocation; % Create
s and plots the line from
b=0*n+(-x(2)+pload); % the di
stributed load to the point load
plot(n,b)
y=-x(2):-x(2)+pload; % Create
s and plots the line for
xx=0*y+plocation; % the po
int load
plot(xx,y)
p=plocation:support2; % Create
s and plots the line from the
q=0*p-x(2); % point
load to the second support
plot(p,q)
% The equations for the moment diagram
slope1=(startlocation*x(1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*startlocation; % Create
s variables to be used in solving
c2=x(1)*startlocation+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=(support2-plocation)*x(2)+(x(2)-pload)*(plocation-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((support2-plocation)*x(2)-((support2-plocation)... % Create
s and plots the line from the end of the
*x(2)+(x(2)-pload)*(plocation-endlocation)))/(plocation-endlocation); % distri
buted load to the point load
tt=endlocation:plocation;
zz=slope2*tt+((support2-plocation)*x(2)+(x(2)-pload)*(plocation...
-endlocation)+abs(slope2)*endlocation);
plot(tt,zz,'r')
slope3=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the point
pp=plocation:support2; % load t
o the second support
qq=slope3*pp+(x(2)*(support2-plocation)+abs(slope3)*plocation);
plot(pp,qq,'r')
hold off;
elseif plocation>startlocation && plocation<endlocation
% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
u=support1:startlocation; % Create
s and plots the line
v=0*u+x(1); % from t
he first support to the distributed load
plot(u,v)
slope=((x(1)-(plocation-startlocation)*distributedload)... % Create
s and plots the line from the start
-x(1))/(plocation-startlocation); % of the
distributed load to the point load
t=startlocation:plocation;
z=slope*t+(x(1)+abs(slope)*startlocation);
plot(t,z)
y=(x(1)-(plocation-startlocation)*distributedload)-pload:(x(1)... % Create
s and plots the line for
-(plocation-startlocation)*distributedload); % the po
int load
xx=0*y+plocation;
plot(xx,y)
n=plocation:endlocation; % Create
s and plots the line from the point load
b=slope*n+((x(1)-(plocation-startlocation)*distributedload)-pload... % to the
end of the distribueted load
+abs(slope)*plocation);
plot(n,b)
m=endlocation:support2; % Create
s and plots the line from the end of the
s=0*m-x(2); % distri
buted load to the second support
plot(m,s)

% The equations for the moment diagram


slope1=(startlocation*x(1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
if (plocation-startlocation)>=(x(1)/distributedload)
nn=startlocation:plocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2; % start
of the distributed load to the point load
plot(nn,mm,'r')
tt=plocation:endlocation; % Create
s and plots the parabola from the
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % point
load to the end of the distributed load
*(tt-plocation);
plot(tt,zz,'r')

elseif (plocation-startlocation)<(x(1)/distributedload)
tt=startlocation:plocation; % Create
s and plots the parabola from the
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2; % start
of the distributed load to the point load
plot(tt,zz,'r')
nn=plocation:endlocation; % Create
s and plots the parabola from the point
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2-pload*(nn... % load t
o the end of the distributed load
-plocation);
plot(nn,mm,'r')

end
slope2=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end
pp=endlocation:support2; % of the
distributed load to the second support
qq=slope2*pp+(x(2)*(support2-endlocation)+abs(slope2)*endlocation);
plot(pp,qq,'r')
hold off;

end

elseif pload==0
% The equations for the shear diagram
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
xx=support1:startlocation; % Create
s and plots the line from
y=0*xx+x(1); % the fi
rst support to the distributed load
plot(xx,y)
slope=(-x(2)-x(1))/(endlocation-startlocation); % Create
s and plots the line for
p=startlocation:endlocation; % the di
stributed load
q=slope*p+(x(1)+abs(slope)*startlocation);
plot(p,q)
t=endlocation:support2; % Create
s and plots the line from
z=0*t-x(2); % the di
stributed load to the second support
plot(t,z)

% The equations for the moment diagram


if mlocation>=endlocation
if signofmoment==1
slope1=(startlocation*x(1)-0)/(startlocation-support1); % Create
s and plots the line from the first
uu=support1:startlocation; % suppor
to the start of the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+.5*(x(1)/distributedload)*x(1); % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+.5*(x(1)/distributedload)*x(1)...
-.5*(endlocation-startlocation-x(1)/distributedload)*x(2);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((x(2)*(support2-mlocation)+moment)-(x(1)*(startlocation... % Create
s and plots the line from the end of
-support1)+.5*(x(1)/distributedload)*x(1)-.5*(endlocation... % the di
stributed load to the location of
-startlocation-x(1)/distributedload)*x(2)))/(mlocation-endlocation); % the mo
ment
tt=endlocation:mlocation;
zz=slope2*tt+x(1)*(startlocation-support1)+.5*(x(1)...
/distributedload)*x(1)-.5*(endlocation-startlocation-x(1)...
/distributedload)*x(2)+abs(slope2)*endlocation;
plot(tt,zz,'r')
f=x(2)*(support2-mlocation):x(2)*(support2-mlocation)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope3=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope3*pp+(x(2)*(support2-mlocation)+abs(slope3)*mlocation);
plot(pp,qq,'r')
hold off;
elseif signofmoment==-1
slope1=(startlocation*x(1)-0)/(startlocation-support1); % Create
s and plots the line from the first
uu=support1:startlocation; % suppor
to the start of the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+.5*(x(1)/distributedload)*x(1); % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+.5*(x(1)/distributedload)*x(1)...
-.5*(endlocation-startlocation-x(1)/distributedload)*x(2);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((x(2)*(support2-mlocation)-moment)-(x(1)*(startlocation... % Create
s and plots the line from the end of
-support1)+.5*(x(1)/distributedload)*x(1)-.5*(endlocation... % the di
stributed load to the location of
-startlocation-x(1)/distributedload)*x(2)))/(mlocation-endlocation); % the mo
ment
tt=endlocation:mlocation;
zz=slope2*tt+x(1)*(startlocation-support1)+.5*(x(1)...
/distributedload)*x(1)-.5*(endlocation-startlocation-x(1)...
/distributedload)*x(2)+abs(slope2)*endlocation;
plot(tt,zz,'r')
f=x(2)*(support2-mlocation)-moment:x(2)*(support2-mlocation); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope3=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope3*pp+(x(2)*(support2-mlocation)+abs(slope3)*mlocation);
plot(pp,qq,'r')
hold off;
end

elseif mlocation<=startlocation
if signofmoment==1
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the first
uu=support1:mlocation; % suppor
t to the moment
vv=slope1*uu-slope1*support1;
plot(uu,vv,'r')
f=x(1)*(mlocation-support1)-moment:x(1)*(mlocation-support1); % Create
s and plots the line for the moment
b=0*f+mlocation;
plot(b,f,'r')
slope2=((x(1)*(startlocation-mlocation)+x(1)*(mlocation-support1)... % Create
s and plots the line from the moment
-moment)-(x(1)*(mlocation-support1)-moment))/(startlocation-mlocation); % to the
start of the distributed load
tt=mlocation:startlocation;
zz=slope2*tt+(x(1)*(mlocation-support1)-moment-abs(slope2)*mlocation);
plot(tt,zz,'r')
c1=x(1)*(startlocation-mlocation)+x(1)*(mlocation-support1)-moment; % Create
s variables to be used in solving
c2=x(1)*(startlocation-mlocation)+x(1)*(mlocation-support1)-moment... % for th
e equation of the parabola
+(x(1)/distributedload)*x(1)*.5;
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
pp=endlocation:support2; % of the
distributed load to the second support
qq=slope3*pp+(x(2)*(support2-endlocation)+abs(slope3)*endlocation);
plot(pp,qq,'r')
hold off;
elseif signofmoment==-1
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the first
uu=support1:mlocation; % suppor
t to the moment
vv=slope1*uu-slope1*support1;
plot(uu,vv,'r')
f=x(1)*(mlocation-support1):x(1)*(mlocation-support1)+moment; % Create
s and plots the line for the moment
b=0*f+mlocation;
plot(b,f,'r')
slope2=((x(1)*(startlocation-mlocation)+moment+x(1)*(mlocation... % Create
s and plots the line from the moment
-support1))-(x(1)*(mlocation-support1)+moment))/(startlocation... % to the
start of the distributed load
-mlocation);
tt=mlocation:startlocation;
zz=slope2*tt+(x(1)*(mlocation-support1)+moment-abs(slope2)*mlocation);
plot(tt,zz,'r')
c1=x(1)*(startlocation-mlocation)+x(1)*(mlocation-support1)+moment; % Create
s variables to be used in solving
c2=x(1)*(startlocation-mlocation)+x(1)*(mlocation-support1)+moment... % for th
e equation of the parabola
+(x(1)/distributedload)*x(1)*.5;
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
pp=endlocation:support2; % of the
distributed load to the second support
qq=slope3*pp+(x(2)*(support2-endlocation)+abs(slope3)*endlocation);
plot(pp,qq,'r')
hold off;
end

elseif mlocation>startlocation && mlocation<endlocation


slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the first
uu=support1:startlocation; % suppor
t to the start of the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
if signofmoment==1
tt=startlocation:mlocation; % Create
s and plots the parabola from the start
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2; % of the
distributed load to the moment
plot(tt,zz,'r')
mm=mlocation:endlocation; % Create
s and plots the parabola from the moment
nn=x(1)*mm-(distributedload/2)*(mm-startlocation).^2-moment; % to the
end of the distributed load
plot(mm,nn,'r')
f=x(1)*mlocation-(distributedload/2)*(mlocation... % Create
s and plots the line for the moment
-startlocation)^2-moment:x(1)*mlocation-(distributedload/2)*...
(mlocation-startlocation)^2;
s=0*f+mlocation;
plot(s,f,'r')
elseif signofmoment==-1
tt=startlocation:mlocation; % Create
s and plots the parabola from the start
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2; % of the
distributed load to the moment
plot(tt,zz,'r')
mm=mlocation:endlocation; % Create
s and plots the parabola from the moment
nn=x(1)*mm-(distributedload/2)*(mm-startlocation).^2+moment; % to the
end of the distributed load
plot(mm,nn,'r')
f=x(1)*mlocation-(distributedload/2)*(mlocation... % Create
s and plots the line for the moment
-startlocation)^2:x(1)*mlocation-(distributedload/2)*...
(mlocation-startlocation)^2+moment;
s=0*f+mlocation;
plot(s,f,'r')

end
slope2=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
pp=endlocation:support2; % the di
stributed load to the second support
qq=slope2*pp+(x(2)*(support2-endlocation)+abs(slope2)*endlocation);
plot(pp,qq,'r')
hold off;
end

else

if plocation<=startlocation
% The equations for the shear diagram if plocation <= startlocation
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
u=support1:plocation; % Create
s and plots the line
v=0*u+x(1); % from t
he first support to the point load
plot(u,v)
y=(x(1)-pload):x(1); % Create
s and plots the line for
xx=0*y+plocation; % the po
int load
plot(xx,y)
p=plocation:startlocation; % Create
s and plots the line from the
q=0*p+(x(1)-pload); % point
load to the distributed load
plot(p,q)
slope=(-x(2)-(x(1)-pload))/(endlocation-startlocation); % Create
s and plots the line for the
t=startlocation:endlocation; % distri
buted load
z=slope*t+(x(1)-pload+abs(slope)*startlocation);
plot(t,z)
n=endlocation:support2; % Create
s and plots the line from the end
b=0*n-x(2); % of the
distributed load to the second support
plot(n,b)
% The equations for the moment diagram if the moment is in plocation <= mlocatio
n <= startlocation
if plocation<=mlocation && mlocation<=startlocation
if signofmoment==1
slope1=(x(1)*(plocation-support1)-0)/(plocation-support1); % Create
s and plots the line from the first
uu=support1:plocation; % suppor
t to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=((x(1)*(plocation-support1)+(x(1)-pload)*(mlocation... % Create
s and plots the line from the point
-plocation))-x(1)*(plocation-support1))/(mlocation-plocation); % load t
o the moment
mm=plocation:mlocation;
nn=slope2*mm+(x(1)*(plocation-support1)-abs(slope2)*plocation);
plot(mm,nn,'r')
f=x(1)*(plocation-support1)+(x(1)-pload)*(mlocation-plocation)... % Create
s and plots the line for the moment
-moment:x(1)*(plocation-support1)+(x(1)-pload)*(mlocation-plocation);
s=0*f+mlocation;
plot(s,f,'r')
slope3=((x(1)*(plocation-support1)+(x(1)-pload)*(mlocation... % Create
s and plots the line from the moment
-plocation)-moment+(x(1)-pload)*(startlocation-mlocation))-(x(1)... % to the
start of the distributed load
*(plocation-support1)+(x(1)-pload)*(mlocation-plocation)-moment))...
/(startlocation-mlocation);
tt=mlocation:startlocation;
zz=slope3*tt+(x(1)*(plocation-support1)+(x(1)-pload)*(mlocation...
-plocation)-moment-abs(slope3)*mlocation);
plot(tt,zz,'r')
c1=(x(1)*(plocation-support1)+(x(1)-pload)*(mlocation... % Create
s variables to be used in solving
-plocation)-moment+(x(1)-pload)*(startlocation-mlocation)); % for th
e equation of the parabola
c2=x(1)*(plocation-support1)+(x(1)-pload)*(mlocation...
-plocation)-moment+(x(1)-pload)*(startlocation-mlocation)...
+(x(1)-pload)/(distributedload)*(x(1)-pload)*.5;
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope4=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of the
pp=endlocation:support2; % distri
buted load to the second support
qq=slope4*pp+(x(2)*(support2-endlocation)+abs(slope4)*endlocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
slope1=(x(1)*(plocation-support1)-0)/(plocation-support1); % Create
s and plots the line from the first
uu=support1:plocation; % suppor
t to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=((x(1)*(plocation-support1)+(x(1)-pload)*(mlocation... % Create
s and plots the line from the point
-plocation))-x(1)*(plocation-support1))/(mlocation-plocation); % load t
o the moment
mm=plocation:mlocation;
nn=slope2*mm+(x(1)*(plocation-support1)-abs(slope2)*plocation);
plot(mm,nn,'r')
f=x(1)*(plocation-support1)+(x(1)-pload)*(mlocation-plocation):x(1)... % Create
s and plots the line for the moment
*(plocation-support1)+(x(1)-pload)*(mlocation-plocation)+moment;
s=0*f+mlocation;
plot(s,f,'r')
slope3=((x(1)*(plocation-support1)+(x(1)-pload)*(mlocation... % Create
s and plots the line from the moment
-plocation)+moment+(x(1)-pload)*(startlocation-mlocation))-(x(1)... % to the
start of the distributed load
*(plocation-support1)+(x(1)-pload)*(mlocation-plocation)+moment))...
/(startlocation-mlocation);
tt=mlocation:startlocation;
zz=slope3*tt+(x(1)*(plocation-support1)+(x(1)-pload)*(mlocation...
-plocation)+moment-abs(slope3)*mlocation);
plot(tt,zz,'r')
c1=(x(1)*(plocation-support1)+(x(1)-pload)*(mlocation... % Create
s variables to be used in solving
-plocation)+moment+(x(1)-pload)*(startlocation-mlocation)); % for th
e equation of the parabola
c2=x(1)*(plocation-support1)+(x(1)-pload)*(mlocation...
-plocation)+moment+(x(1)-pload)*(startlocation-mlocation)...
+(x(1)-pload)/(distributedload)*(x(1)-pload)*.5;
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope4=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of the
pp=endlocation:support2; % distri
buted load to the second support
qq=slope4*pp+(x(2)*(support2-endlocation)+abs(slope4)*endlocation);
plot(pp,qq,'r')
hold off;
end % End fo
r "if signofmoment = 1"
end % End fo
r "if plocation <= mlocation <= startlocation"
% The equations for the moment diagram if the moment is in mlocation >= endlocat
ion
if mlocation>=endlocation
if signofmoment==1
slope1=(x(1)*(plocation-support1)-0)/(plocation-support1); % Create
s and plots the line from the first
uu=support1:plocation; % suppor
t to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=((x(1)*(plocation-support1)+(x(1)-pload)*(startlocation... % Create
s and plots the line from the point
-plocation))-(x(1)*(plocation-support1)))/(startlocation-plocation); % load t
o the start of the distributed load
mm=plocation:startlocation;
nn=slope2*mm+(x(1)*(plocation-support1)-abs(slope2)*plocation);
plot(mm,nn,'r')
c1=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation); % Create
s variables to be used in solving
c2=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % for th
e equation of the parabola
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5;
c3=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)...
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5-((endlocation...
-startlocation-(x(1)-pload)/distributedload)*x(2)*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=((x(2)*(support2-mlocation)+moment)-(x(2)*(support2... % Create
s and plots the line from the end of
-mlocation)+moment+x(2)*(mlocation-endlocation)))/(mlocation... % distri
buted load to the moment
-endlocation);
tt=endlocation:mlocation;
zz=slope3*tt+(x(2)*(support2-mlocation)+moment+x(2)*(mlocation...
-endlocation)+abs(slope3)*endlocation);
plot(tt,zz,'r')
f=x(2)*(support2-mlocation):x(2)*(support2-mlocation)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope4=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope4*pp+(x(2)*(support2-mlocation)+abs(slope4)*mlocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
slope1=(x(1)*(plocation-support1)-0)/(plocation-support1); % Create
s and plots the line from the first
uu=support1:plocation; % suppor
t to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=((x(1)*(plocation-support1)+(x(1)-pload)*(startlocation... % Create
s and plots the line from the point
-plocation))-(x(1)*(plocation-support1)))/(startlocation-plocation); % load t
o the start of the distributed load
mm=plocation:startlocation;
nn=slope2*mm+(x(1)*(plocation-support1)-abs(slope2)*plocation);
plot(mm,nn,'r')
c1=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation); % Create
s variables to be used in solving
c2=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % for th
e equation of the parabola
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5;
c3=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)...
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5-((endlocation...
-startlocation-(x(1)-pload)/distributedload)*x(2)*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=((x(2)*(support2-mlocation)-moment)-(x(2)*(support2... % Create
s and plots the line from the end of
-mlocation)-moment+x(2)*(mlocation-endlocation)))/(mlocation... % distri
buted load to the moment
-endlocation);
tt=endlocation:mlocation;
zz=slope3*tt+(x(2)*(support2-mlocation)-moment+x(2)*(mlocation...
-endlocation)+abs(slope3)*endlocation);
plot(tt,zz,'r')
f=x(2)*(support2-mlocation)-moment:x(2)*(support2-mlocation); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope4=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope4*pp+(x(2)*(support2-mlocation)+abs(slope4)*mlocation);
plot(pp,qq,'r')
hold off;
end % End fo
r "if signofmoment = 1"
end % End fo
r "if mlocation >= endlocation"

% The equations for the moment diagram if the moment is in startlocation < mloca
tion < endlocation
if mlocation>startlocation && mlocation<endlocation
if signofmoment==1
slope1=(x(1)*(plocation-support1)-0)/(plocation-support1); % Create
s and plots the line from the first
uu=support1:plocation; % supppo
rt to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=((x(1)*(plocation-support1)+(x(1)-pload)*(startlocation... % Create
s and plots the line from the point
-plocation))-(x(1)*(plocation-support1)))/(startlocation-plocation); % load t
o the start of the distributed load
nn=plocation:startlocation;
mm=slope2*nn+(x(1)*plocation-abs(slope2)*plocation);
plot(nn,mm,'r')
if (mlocation-startlocation)>((x(1)-pload)/distributedload)
c1=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation); % Create
s variables to be used in solving
c2=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % for th
e equation of the parabola
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5;
c3=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)...
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5-((mlocation...
-startlocation-(x(1)-pload)/distributedload)*(x(2)-distributedload...
*(endlocation-mlocation))*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=mlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
f=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % Create
s and plots the line for the moment
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5-((mlocation...
-startlocation-(x(1)-pload)/distributedload)*(x(2)-distributedload...
*(endlocation-mlocation))*.5)-moment:x(1)*(plocation-support1)...
+(x(1)-pload)*(startlocation-plocation)+((x(1)-pload)...
/distributedload)*(x(1)-pload)*.5-((mlocation-startlocation-(x(1)...
-pload)/distributedload)*(x(2)-distributedload*(endlocation...
-mlocation))*.5);
s=0*f+mlocation;
plot(s,f,'r')
tt=mlocation:endlocation; % Create
s and plots the parabola from the
zz=a(1)*(tt).^2+a(2)*tt+a(3)-moment; % moment
to the end of the distributed load
plot(tt,zz,'r')

elseif (mlocation-startlocation)<((x(1)-pload)/distributedload)
c1=x(2)*(support2-endlocation)+(endlocation-startlocation-(x(1)... % Create
s variables to be used in solving
-pload)/distributedload)*x(2)*.5-(((x(1)-pload)/distributedload... % for th
e equation of the parabola
-(mlocation-startlocation))*(x(1)-pload-distributedload*(mlocation...
-startlocation))*.5);
c2=x(2)*(support2-endlocation)+(endlocation-startlocation-(x(1)...
-pload)/distributedload)*x(2)*.5;
c3=x(2)*(support2-endlocation);
r1=mlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=mlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % moment
to the end of the distributed load
plot(d,yy,'r')
f=x(2)*(support2-endlocation)+(endlocation-startlocation-(x(1)... % Create
s and plots the line for the moment
-pload)/distributedload)*x(2)*.5-(((x(1)-pload)/distributedload...
-(mlocation-startlocation))*(x(1)-pload-distributedload*(mlocation...
-startlocation))*.5):x(2)*(support2-endlocation)+(endlocation...
-startlocation-(x(1)-pload)/distributedload)*x(2)*.5-(((x(1)-pload)...
/distributedload-(mlocation-startlocation))*(x(1)-pload...
-distributedload*(mlocation-startlocation))*.5)+moment;
s=0*f+mlocation;
plot(s,f,'r')
pp=startlocation:mlocation; % Create
s and plots the parabola from the start
qq=a(1)*(pp).^2+a(2)*pp+a(3)+moment; % of the
distributed load to the moment
plot(pp,qq,'r')

elseif (mlocation-startlocation)==((x(1)-pload)/distributedload)
c1=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation); % Create
s variables to be used in solving
c2=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % for th
e equation of the parabola
+(x(1)-pload)*(mlocation-startlocation)*.5;
c3=x(2)*(support2-endlocation)+moment;
r1=startlocation; % Create
s variables to be used in solving
r2=mlocation; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % Create
s and plots the line for the moment
+(x(1)-pload)*(mlocation-startlocation)*.5-moment:x(1)*(plocation...
-support1)+(x(1)-pload)*(startlocation-plocation)+(x(1)-pload)...
*(mlocation-startlocation)*.5;
s=0*f+mlocation;
plot(s,f,'r')
tt=mlocation:endlocation; % Create
s and plots the parabola from the
zz=a(1)*(tt).^2+a(2)*tt+a(3)+moment; % moment
to the end of the distributed load
plot(tt,zz,'r')
end
slope3=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end
pp=endlocation:support2; % of the
distributed load to the second support
qq=slope3*pp+(x(2)*(support2-endlocation)+abs(slope3)*endlocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
slope1=(x(1)*(plocation-support1)-0)/(plocation-support1); % Create
s and plots the line from the first
uu=support1:plocation; % supppo
rt to the point load
vv=slope1*uu+0;
plot(uu,vv,'r')
slope2=((x(1)*(plocation-support1)+(x(1)-pload)*(startlocation... % Create
s and plots the line from the point
-plocation))-(x(1)*(plocation-support1)))/(startlocation-plocation); % load t
o the start of the distributed load
nn=plocation:startlocation;
mm=slope2*nn+(x(1)*plocation-abs(slope2)*plocation);
plot(nn,mm,'r')
if (mlocation-startlocation)>((x(1)-pload)/distributedload)
c1=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation); % Create
s variables to be used in solving
c2=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % for th
e equation of the parabola
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5;
c3=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)...
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5-((mlocation...
-startlocation-(x(1)-pload)/distributedload)*(x(2)-distributedload...
*(endlocation-mlocation))*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=mlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % Create
s and plots the line for the moment
+((x(1)-pload)/distributedload)*(x(1)-pload)*.5-((mlocation...
-startlocation-(x(1)-pload)/distributedload)*(x(2)-distributedload...
*(endlocation-mlocation))*.5):x(1)*(plocation-support1)+(x(1)-pload)...
*(startlocation-plocation)+((x(1)-pload)/distributedload)*(x(1)...
-pload)*.5-((mlocation-startlocation-(x(1)-pload)/distributedload)...
*(x(2)-distributedload*(endlocation-mlocation))*.5)+moment;
s=0*f+mlocation;
plot(s,f,'r')
tt=mlocation:endlocation; % Create
s and plots the parabola from the
zz=a(1)*(tt).^2+a(2)*tt+a(3)+moment; % moment
to the end of the distributed load
plot(tt,zz,'r')

elseif (mlocation-startlocation)<((x(1)-pload)/distributedload)
c1=x(2)*(support2-endlocation)+(endlocation-startlocation-(x(1)... % Create
s variables to be used in solving
-pload)/distributedload)*x(2)*.5-(((x(1)-pload)/distributedload... % for th
e equation of the parabola
-(mlocation-startlocation))*(x(1)-pload-distributedload*(mlocation...
-startlocation))*.5);
c2=x(2)*(support2-endlocation)+(endlocation-startlocation-(x(1)...
-pload)/distributedload)*x(2)*.5;
c3=x(2)*(support2-endlocation);
r1=mlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=mlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % moment
to the end of the distributed load
plot(d,yy,'r')
f=x(2)*(support2-endlocation)+(endlocation-startlocation-(x(1)... % Create
s and plots the line for the moment
-pload)/distributedload)*x(2)*.5-(((x(1)-pload)/distributedload...
-(mlocation-startlocation))*(x(1)-pload-distributedload*(mlocation...
-startlocation))*.5)-moment:x(2)*(support2-endlocation)+(endlocation...
-startlocation-(x(1)-pload)/distributedload)*x(2)*.5-(((x(1)-pload)...
/distributedload-(mlocation-startlocation))*(x(1)-pload...
-distributedload*(mlocation-startlocation))*.5);
s=0*f+mlocation;
plot(s,f,'r')
pp=startlocation:mlocation; % Create
s and plots the line from the start
qq=a(1)*(pp).^2+a(2)*pp+a(3)-moment; % of the
distributed load to the moment
plot(pp,qq,'r')

elseif (mlocation-startlocation)==((x(1)-pload)/distributedload)
c1=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation); % Create
s variables to be used in solving
c2=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % for th
e equation of the parabola
+(x(1)-pload)*(mlocation-startlocation)*.5;
c3=x(2)*(support2-endlocation)-moment;
r1=startlocation; % Create
s variables to be used in solving
r2=mlocation; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(1)*(plocation-support1)+(x(1)-pload)*(startlocation-plocation)... % Create
s and plots the line for the moment
+(x(1)-pload)*(mlocation-startlocation)*.5:x(1)*(plocation...
-support1)+(x(1)-pload)*(startlocation-plocation)+(x(1)-pload)...
*(mlocation-startlocation)*.5+moment;
s=0*f+mlocation;
plot(s,f,'r')
tt=mlocation:endlocation; % Create
s and plots the parabola from the
zz=a(1)*(tt).^2+a(2)*tt+a(3)-moment; % moment
to the end of the distributed load
plot(tt,zz,'r')

end
slope3=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end
pp=endlocation:support2; % of the
distributed load to the second support
qq=slope3*pp+(x(2)*(support2-endlocation)+abs(slope3)*endlocation);
plot(pp,qq,'r')
hold off;
end % End fo
r "if signofmoment = 1"
end % End fo
r "if startlocation < mlocation < endlocation"

% The equations for the moment diagram if the moment is in mlocation < plocation
if mlocation<plocation
if signofmoment==1
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the
uu=support1:mlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
f=x(1)*(mlocation-support1)-moment:x(1)*(mlocation-support1); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope2=((x(1)*(mlocation-support1)-moment+x(1)*(plocation... % Create
s and plots the line from the moment
-mlocation))-(x(1)*(mlocation-support1)-moment))/(plocation-mlocation); % to the
point load
mm=mlocation:plocation;
nn=mm*slope2+(x(1)*(mlocation-support1)-moment-abs(slope2)*mlocation);
plot(mm,nn,'r')
slope3=((x(1)*(mlocation-support1)-moment+x(1)*(plocation-mlocation)... % Create
s and plots the line from the point
+(x(1)-pload)*(startlocation-plocation))-(x(1)*(mlocation-support1)... % load t
o the start of the distributed load
-moment+x(1)*(plocation-mlocation)))/(startlocation-plocation);
tt=plocation:startlocation;
zz=slope3*tt+(x(1)*(mlocation-support1)-moment+x(1)*(plocation...
-mlocation)-abs(slope3)*plocation);
plot(tt,zz,'r')
c1=x(1)*(mlocation-support1)-moment+x(1)*(plocation-mlocation)... % Create
s variables to be used in solving
+(x(1)-pload)*(startlocation-plocation);
c2=x(1)*(mlocation-support1)-moment+x(1)*(plocation-mlocation)... % for th
e equation of the parabola
+(x(1)-pload)*(startlocation-plocation)+(x(1)-pload)/distributedload...
*(endlocation-startlocation)*.5;
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope4=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of the
pp=endlocation:support2; % distri
buted load to the second support
qq=slope4*pp+(x(2)*(support2-endlocation)+abs(slope4)*endlocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the
uu=support1:mlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
f=x(1)*(mlocation-support1):x(1)*(mlocation-support1)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope2=((x(1)*(mlocation-support1)+moment+x(1)*(plocation... % Create
s and plots the line from the moment
-mlocation))-(x(1)*(mlocation-support1)+moment))/(plocation-mlocation); % to the
point load
mm=mlocation:plocation;
nn=mm*slope2+(x(1)*(mlocation-support1)+moment-abs(slope2)*mlocation);
plot(mm,nn,'r')
slope3=((x(1)*(mlocation-support1)+moment+x(1)*(plocation-mlocation)... % Create
s and plots the line from the point
+(x(1)-pload)*(startlocation-plocation))-(x(1)*(mlocation-support1)... % load t
o the start of the distributed load
+moment+x(1)*(plocation-mlocation)))/(startlocation-plocation);
tt=plocation:startlocation;
zz=slope3*tt+(x(1)*(mlocation-support1)+moment+x(1)*(plocation...
-mlocation)-abs(slope3)*plocation);
plot(tt,zz,'r')
c1=x(1)*(mlocation-support1)+moment+x(1)*(plocation-mlocation)... % Create
s variables to be used in solving
+(x(1)-pload)*(startlocation-plocation);
c2=x(1)*(mlocation-support1)+moment+x(1)*(plocation-mlocation)... % for th
e equation of the parabola
+(x(1)-pload)*(startlocation-plocation)+(x(1)-pload)/distributedload...
*(endlocation-startlocation)*.5;
c3=x(2)*(support2-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+(x(1)-pload)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope4=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of the
pp=endlocation:support2; % distri
buted load to the second support
qq=slope4*pp+(x(2)*(support2-endlocation)+abs(slope4)*endlocation);
plot(pp,qq,'r')
hold off;
end % End fo
r "if signofmoment = 1"
end % End fo
r "if mlocation < plocation"
end % End fo
r if "plocation <= startlocation"

if plocation>=endlocation
% The equations for the shear diagram if plocation >= endlocation
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
u=support1:startlocation; % Create
s and plots the line
v=0*u+x(1); % from t
he first support to the distributed load
plot(u,v)
slope=((-x(2)+pload)-x(1))/(endlocation-startlocation); % Create
s and plots the line for the
p=startlocation:endlocation; % distri
buted load
q=slope*p+(x(1)+abs(slope)*startlocation);
plot(p,q)
t=endlocation:plocation; % Create
s and plots the line from the end of
z=0*t+(-x(2)+pload); % the di
stributed load to the point load
plot(t,z)
y=-x(2):-x(2)+pload; % Create
s and plots the line for the point
xx=0*y+plocation; % load
plot(xx,y)
m=plocation:support2; % Create
s and plots the line from the point
n=0*m-x(2); % load t
o the second support
plot(m,n)

% The equations for the moment diagram if the moment is in endlocation <= mlocat
ion <= plocation
if mlocation<=plocation && mlocation>=endlocation
if signofmoment==1
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5...
-((endlocation-startlocation-x(1)/distributedload)*(x(2)-pload)*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((x(2)*(support2-plocation)+(x(2)-pload)*(plocation... % Create
s and plots the line from the end of
-mlocation)+moment)-(x(2)*(support2-plocation)+(x(2)-pload)... % of the
distributed load to the moment
*(plocation-mlocation)+moment+(x(2)-pload)*(mlocation-endlocation)))...
/(mlocation-endlocation);
mm=endlocation:mlocation;
nn=slope2*mm+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-mlocation)+moment+(x(2)-pload)*(mlocation-endlocation)...
+abs(slope2)*endlocation);
plot(mm,nn,'r')
f=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-mlocation):x(2)... % Create
s and plots the line for the moment
*(support2-plocation)+(x(2)-pload)*(plocation-mlocation)+moment;
s=0*f+mlocation;
plot(s,f,'r')
slope3=((x(2)*(support2-plocation))-(x(2)*(support2-plocation)... % Create
s and plots the line from the moment
+(x(2)-pload)*(plocation-mlocation)))/(plocation-mlocation); % to the
point load
tt=mlocation:plocation;
zz=slope3*tt+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-mlocation)+abs(slope3)*mlocation);
plot(tt,zz,'r')
slope4=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the point
pp=plocation:support2; % load t
o the second support
qq=slope4*pp+(x(2)*(support2-plocation)+abs(slope4)*plocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5...
-((endlocation-startlocation-x(1)/distributedload)*(x(2)-pload)*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((x(2)*(support2-plocation)+(x(2)-pload)*(plocation... % Create
s and plots the line from the end of
-mlocation)-moment)-(x(2)*(support2-plocation)+(x(2)-pload)... % of the
distributed load to the moment
*(plocation-mlocation)-moment+(x(2)-pload)*(mlocation-endlocation)))...
/(mlocation-endlocation);
mm=endlocation:mlocation;
nn=slope2*mm+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-mlocation)-moment+(x(2)-pload)*(mlocation-endlocation)...
+abs(slope2)*endlocation);
plot(mm,nn,'r')
f=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-mlocation)... % Create
s and plots the line for the moment
-moment:x(2)*(support2-plocation)+(x(2)-pload)*(plocation-mlocation);
s=0*f+mlocation;
plot(s,f,'r')
slope3=((x(2)*(support2-plocation))-(x(2)*(support2-plocation)... % Create
s and plots the line from the moment
+(x(2)-pload)*(plocation-mlocation)))/(plocation-mlocation); % to the
point load
tt=mlocation:plocation;
zz=slope3*tt+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-mlocation)+abs(slope3)*mlocation);
plot(tt,zz,'r')
slope4=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the point
pp=plocation:support2; % load t
o the second support
qq=slope4*pp+(x(2)*(support2-plocation)+abs(slope4)*plocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if signofmoment = 1"
end % End fo
r "if endlocation <= mlocation <= plocation"

% The equations for the moment diagram if the moment is in mlocation >= plocatio
n
if mlocation>plocation
if signofmoment==1
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5...
-((endlocation-startlocation-x(1)/distributedload)*(x(2)-pload)*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((x(2)*(support2-mlocation)+moment+x(2)*(mlocation... % Create
s and plots the line from the end
-plocation))-(x(2)*(support2-mlocation)+moment+x(2)*(mlocation... % of the
distributed load to the point load
-plocation)+(x(2)-pload)*(plocation-endlocation)))/(plocation...
-endlocation);
mm=endlocation:plocation;
nn=slope2*mm+(x(2)*(support2-mlocation)+moment+x(2)*(mlocation...
-plocation)+(x(2)-pload)*(plocation-endlocation)+abs(slope2)...
*endlocation);
plot(mm,nn,'r')
slope3=((x(2)*(support2-mlocation)+moment)-(x(2)*(support2... % Create
s and plots the line from the point
-mlocation)+moment+x(2)*(mlocation-plocation)))/(mlocation-plocation); % load t
o the moment
tt=plocation:mlocation;
zz=slope3*tt+(x(2)*(support2-mlocation)+moment+x(2)*(mlocation...
-plocation)+abs(slope3)*plocation);
plot(tt,zz,'r')
f=x(2)*(support2-mlocation):x(2)*(support2-mlocation)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope4=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope4*pp+(x(2)*(support2-mlocation)+abs(slope4)*mlocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"

slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5...
-((endlocation-startlocation-x(1)/distributedload)*(x(2)-pload)*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope2=((x(2)*(support2-mlocation)-moment+x(2)*(mlocation... % Create
s and plots the line from the end
-plocation))-(x(2)*(support2-mlocation)-moment+x(2)*(mlocation... % of the
distributed load to the point load
-plocation)+(x(2)-pload)*(plocation-endlocation)))/(plocation...
-endlocation);
mm=endlocation:plocation;
nn=slope2*mm+(x(2)*(support2-mlocation)-moment+x(2)*(mlocation...
-plocation)+(x(2)-pload)*(plocation-endlocation)+abs(slope2)...
*endlocation);
plot(mm,nn,'r')
slope3=((x(2)*(support2-mlocation)-moment)-(x(2)*(support2... % Create
s and plots the line from the point
-mlocation)-moment+x(2)*(mlocation-plocation)))/(mlocation-plocation); % load t
o the moment
tt=plocation:mlocation;
zz=slope3*tt+(x(2)*(support2-mlocation)-moment+x(2)*(mlocation...
-plocation)+abs(slope3)*plocation);
plot(tt,zz,'r')
f=x(2)*(support2-mlocation)-moment:x(2)*(support2-mlocation); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope4=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope4*pp+(x(2)*(support2-mlocation)+abs(slope4)*mlocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if signofmoment = 1"
end % End fo
r "if mlocation >= plocation"

% The equations for the moment diagram if the moment is in mlocation <= startloc
ation
if mlocation<=startlocation
if signofmoment==1
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the
uu=support1:mlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
f=x(1)*(mlocation-support1)-moment:x(1)*(mlocation-support1); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope2=((x(1)*(mlocation-support1)-moment+x(1)*(startlocation... % Create
s and plots the line from the
-mlocation))-(x(1)*(mlocation-support1)-moment))... % moment
to the start of the distributed load
/(startlocation-mlocation);
mm=mlocation:startlocation;
nn=slope2*mm+(x(1)*(mlocation-support1)-moment-abs(slope2)*mlocation);
plot(mm,nn,'r')
c1=x(1)*(mlocation-support1)-moment+x(1)*(startlocation-mlocation); % Create
s variables to be used in solving
c2=x(1)*(mlocation-support1)-moment+x(1)*(startlocation-mlocation)... % for th
e equation of the parabola
+(x(1)/distributedload)*x(1)*.5;
c3=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=((x(2)*(support2-plocation))-(x(2)*(support2-plocation)... % Create
s and plots the line from the end of
+(x(2)-pload)*(plocation-endlocation)))/(plocation-endlocation); % the di
stributed load to the point load
tt=endlocation:plocation;
zz=slope3*tt+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-endlocation)+abs(slope3)*endlocation);
plot(tt,zz,'r')
slope4=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the
pp=plocation:support2; % point
load to the second support
qq=slope4*pp+(x(2)*(support2-plocation)+abs(slope4)*plocation);
plot(pp,qq,'r')
hold off;
elseif signofmoment==-1 % Else f
or "if signofmoment = 1"
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the
uu=support1:mlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
f=x(1)*(mlocation-support1):x(1)*(mlocation-support1)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope2=((x(1)*(mlocation-support1)+moment+x(1)*(startlocation... % Create
s and plots the line from the
-mlocation))-(x(1)*(mlocation-support1)+moment))... % moment
to the start of the distributed load
/(startlocation-mlocation);
mm=mlocation:startlocation;
nn=slope2*mm+(x(1)*(mlocation-support1)+moment-abs(slope2)*mlocation);
plot(mm,nn,'r')
c1=x(1)*(mlocation-support1)+moment+x(1)*(startlocation-mlocation); % Create
s variables to be used in solving
c2=x(1)*(mlocation-support1)+moment+x(1)*(startlocation-mlocation)... % for th
e equation of the parabola
+(x(1)/distributedload)*x(1)*.5;
c3=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the end
plot(d,yy,'r')
slope3=((x(2)*(support2-plocation))-(x(2)*(support2-plocation)... % Create
s and plots the line from the end of
+(x(2)-pload)*(plocation-endlocation)))/(plocation-endlocation); % the di
stributed load to the point load
tt=endlocation:plocation;
zz=slope3*tt+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-endlocation)+abs(slope3)*endlocation);
plot(tt,zz,'r')
slope4=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the
pp=plocation:support2; % point
load to the second support
qq=slope4*pp+(x(2)*(support2-plocation)+abs(slope4)*plocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if signofmoment = 1"
end % End fo
r "if mlocation <= startlocation"

% The equations for the moment diagram if the moment is in startlocation < mloca
tion < endlocation
if mlocation>startlocation && mlocation<endlocation
if signofmoment==1
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the first
uu=support1:startlocation; % suppor
t to the start of the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
if (mlocation-startlocation)>(x(1)/distributedload)
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5...
-((mlocation-startlocation-x(1)/distributedload)*(distributedload...
*(mlocation-startlocation)-x(1))*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=mlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5... % Create
s and plots the line for the moment
-((mlocation-startlocation-x(1)/distributedload)*(distributedload...
*(mlocation-startlocation)-x(1))*.5)-moment:x(1)*(startlocation...
-support1)+(x(1)/distributedload)*x(1)*.5-((mlocation-startlocation...
-x(1)/distributedload)*(distributedload*(mlocation-startlocation)...
-x(1))*.5);
s=0*f+mlocation;
plot(s,f,'r')
nn=mlocation:endlocation; % Create
s and plots the parabola from the
mm=a(1)*(nn).^2+a(2)*nn+a(3)-moment; % moment
to the end of the distributed load
plot(nn,mm,'r')

elseif (mlocation-startlocation)<(x(1)/distributedload)
c1=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)... % Create
s variables to be used in solving
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5... % for th
e equation of the parabola
-(x(1)-distributedload*(mlocation-startlocation))*(x(1)...
/distributedload-(mlocation-startlocation))*.5;
c2=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)...
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5;
c3=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation);
r1=mlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=mlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)... % Create
s and plots the line for the moment
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5...
-(x(1)-distributedload*(mlocation-startlocation))*(x(1)...
/distributedload-(mlocation-startlocation))*.5:x(2)*(support2...
-plocation)+(x(2)-pload)*(plocation-endlocation)...
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5...
-(x(1)-distributedload*(mlocation-startlocation))*(x(1)...
/distributedload-(mlocation-startlocation))*.5+moment;
s=0*f+mlocation;
plot(s,f,'r')
nn=startlocation:mlocation; % Create
s and plots the parabola from the
mm=a(1)*(nn).^2+a(2)*nn+a(3)+moment; % moment
to the end of the distributed load
plot(nn,mm,'r')
elseif (mlocation-startlocation)==(x(1)/distributedload)
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)...
+moment;
r1=startlocation; % Create
s variables to be used in solving
r2=mlocation; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(2)*(support2-plocation)+(x(2)-pload)*(plocation... % Create
s and plots the line for the moment
-endlocation):x(1)*(startlocation-support1)+(x(1)/distributedload)...
*x(1)*.5;
s=0*f+mlocation;
plot(s,f,'r')
nn=mlocation:endlocation; % Create
s and plots the parabola from the
mm=a(1)*(nn).^2+a(2)*nn+a(3)-moment; % moment
to the end of the distributed load
plot(nn,mm,'r')

end
slope2=((x(2)*(support2-plocation))-(x(2)*(support2-plocation)+(x(2)... % Create
s and plots the line from the end of
-pload)*(plocation-endlocation)))/(plocation-endlocation); % the di
stributed load to the point load
tt=endlocation:plocation;
zz=slope2*tt+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-endlocation)+abs(slope2)*endlocation);
plot(tt,zz,'r')
slope3=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the point
pp=plocation:support2; % load t
o the distributed load
qq=slope3*pp+(x(2)*(support2-plocation)+abs(slope3)*plocation);
plot(pp,qq,'r')
hold off;

elseif signofmoment==-1
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the first
uu=support1:startlocation; % suppor
t to the start of the distributed load
vv=slope1*uu+0;
plot(uu,vv,'r')
if (mlocation-startlocation)>(x(1)/distributedload)
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5...
-((mlocation-startlocation-x(1)/distributedload)*(distributedload...
*(mlocation-startlocation)-x(1))*.5);
r1=startlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=mlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5... % Create
s and plots the line for the moment
-((mlocation-startlocation-x(1)/distributedload)*(distributedload...
*(mlocation-startlocation)-x(1))*.5):x(1)*(startlocation...
-support1)+(x(1)/distributedload)*x(1)*.5-((mlocation-startlocation...
-x(1)/distributedload)*(distributedload*(mlocation-startlocation)...
-x(1))*.5)+moment;
s=0*f+mlocation;
plot(s,f,'r')
nn=mlocation:endlocation; % Create
s and plots the parabola from the
mm=a(1)*(nn).^2+a(2)*nn+a(3)+moment; % moment
to the end of the distributed load
plot(nn,mm,'r')

elseif (mlocation-startlocation)<(x(1)/distributedload)
c1=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)... % Create
s variables to be used in solving
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5... % for th
e equation of the parabola
-(x(1)-distributedload*(mlocation-startlocation))*(x(1)...
/distributedload-(mlocation-startlocation))*.5;
c2=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)...
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5;
c3=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation);
r1=mlocation; % Create
s variables to be used in solving
r2=startlocation+x(1)/distributedload; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=mlocation:endlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)... % Create
s and plots the line for the moment
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5...
-(x(1)-distributedload*(mlocation-startlocation))*(x(1)...
/distributedload-(mlocation-startlocation))*.5-moment:x(2)...
*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)...
+(x(2)-pload)*(endlocation-startlocation-x(1)/distributedload)*.5...
-(x(1)-distributedload*(mlocation-startlocation))*(x(1)...
/distributedload-(mlocation-startlocation))*.5;
s=0*f+mlocation;
plot(s,f,'r')
nn=startlocation:mlocation; % Create
s and plots the parabola from the
mm=a(1)*(nn).^2+a(2)*nn+a(3)-moment; % moment
to the end of the distributed load
plot(nn,mm,'r')

elseif (mlocation-startlocation)==(x(1)/distributedload)
c1=x(1)*(startlocation-support1); % Create
s variables to be used in solving
c2=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5; % for th
e equation of the parabola
c3=x(2)*(support2-plocation)+(x(2)-pload)*(plocation-endlocation)...
-moment;
r1=startlocation; % Create
s variables to be used in solving
r2=mlocation; % for th
e equation of the parabola
r3=endlocation;
R=[(r1)^2 r1 1;(r2)^2 r2 1; (r3)^2 r3 1]; % Create
s the matrices used to solve
W=[c1;c2;c3]; % for th
e coefficients of the parabola
a=inv(R)*W; % Solves
for the coefficients of the parabola
d=startlocation:mlocation; % Create
s and plots the parabola from the
yy=a(1)*(d).^2+a(2)*d+a(3); % beginn
ing of the distributed load to the moment
plot(d,yy,'r')
f=x(1)*(startlocation-support1)+(x(1)/distributedload)*x(1)*.5:x(2)... % Create
s and plots the line for the moment
*(support2-plocation)+(x(2)-pload)*(plocation-endlocation);
s=0*f+mlocation;
plot(s,f,'r')
nn=mlocation:endlocation; % Create
s and plots the parabola from the
mm=a(1)*(nn).^2+a(2)*nn+a(3)+moment; % moment
to the end of the distributed load
plot(nn,mm,'r')

end
slope2=((x(2)*(support2-plocation))-(x(2)*(support2-plocation)+(x(2)... % Create
s and plots the line from the end of
-pload)*(plocation-endlocation)))/(plocation-endlocation); % the di
stributed load to the point load
tt=endlocation:plocation;
zz=slope2*tt+(x(2)*(support2-plocation)+(x(2)-pload)*(plocation...
-endlocation)+abs(slope2)*endlocation);
plot(tt,zz,'r')
slope3=(0-x(2)*(support2-plocation))/(support2-plocation); % Create
s and plots the line from the point
pp=plocation:support2; % load t
o the distributed load
qq=slope3*pp+(x(2)*(support2-plocation)+abs(slope3)*plocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if signofmoment = 1"
end % End fo
r "if mlocation > startlocation & mlocation < endlocation"
end % End fo
r if "plocation >= endlocation"

if plocation<endlocation && plocation>startlocation


% The equations for the shear diagram if plocation < endlocation & plocation > s
tartlocation
f1=0:x(1); % Create
s and plots the line
r1=0*f1+support1; % for th
e first support used by the beam
hold on;
plot(r1,f1)
f2=-x(2):0; % Create
s and plots the line
r2=0*f2+support2; % for th
e second support used by the beam
plot(r2,f2)
u=support1:startlocation; % Create
s and plots the line from the
v=0*u+x(1); % first
support to the distributed load
plot(u,v)
slope=-distributedload; % Create
s and plots the line from the start
p=startlocation:plocation; % of the
distributed load to the point load
q=slope*p+(x(1)+abs(slope)*startlocation);
plot(p,q)
y=x(1)-distributedload*(plocation-startlocation)-pload:x(1)... % Create
s and plots the line for the
-distributedload*(plocation-startlocation); % point
load
xx=0*y+plocation;
plot(xx,y)
t=plocation:endlocation; % Create
s and plots the line from the point
z=slope*t+(x(1)-distributedload*(plocation-startlocation)... % load t
o the end of the distributed load
-pload+abs(slope)*plocation);
plot(t,z)
n=endlocation:support2;
b=0*n-x(2);
plot(n,b)

% The equations for the moment diagrams if the moment is in the location mlocati
on <= startlocation
if mlocation<=startlocation
slope1=(x(1)*(mlocation-support1)-0)/(mlocation-support1); % Create
s and plots the line from the
uu=support1:mlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
if signofmoment==1
f=x(1)*(mlocation-support1)-moment:x(1)*(mlocation-support1); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope2=((x(1)*(mlocation-support1)-moment+x(1)*(startlocation... % Create
s and plots the line from the moment
-mlocation))-(x(1)*(mlocation-support1)-moment))/(startlocation... % to the
start of the distributed load
-mlocation);
nn=mlocation:startlocation;
mm=slope2*nn+(x(1)*(mlocation-support1)-moment-abs(slope2)*mlocation);
plot(nn,mm,'r')
nn=startlocation:plocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2-moment; % start
of the distributed load to the point load
plot(nn,mm,'r')
tt=plocation:endlocation; % Create
s and plots the parabola from the
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % point
load to the end of the distributed load
*(tt-plocation)-moment;
plot(tt,zz,'r')

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
f=x(1)*(mlocation-support1):x(1)*(mlocation-support1)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')
slope2=((x(1)*(mlocation-support1)+moment+x(1)*(startlocation... % Create
s and plots the line from the moment
-mlocation))-(x(1)*(mlocation-support1)+moment))/(startlocation... % to the
start of the distributed load
-mlocation);
nn=mlocation:startlocation;
mm=slope2*nn+(x(1)*(mlocation-support1)+moment-abs(slope2)*mlocation);
plot(nn,mm,'r')
nn=startlocation:plocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2+moment; % start
of the distributed load to the point load
plot(nn,mm,'r')
tt=plocation:endlocation; % Create
s and plots the parabola from the
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % point
load to the end of the distributed load
*(tt-plocation)+moment;
plot(tt,zz,'r')

end % End fo
r "if signofmoment = 1"
slope3=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
pp=endlocation:support2; % the di
stributed load to the second support
qq=slope3*pp+(x(2)*(support2-endlocation)+abs(slope3)*endlocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if mlocation <= startlocation"
% The equations for the moment diagrams if the moment is in the location mlocati
on >= endlocation
if mlocation>=endlocation
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
if signofmoment==1
nn=startlocation:plocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2; % start
of the distributed load to the point load
plot(nn,mm,'r')
tt=plocation:endlocation; % Create
s and plots the parabola from the
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % point
load to the end of the distributed load
*(tt-plocation);
plot(tt,zz,'r')
slope2=((x(2)*(support2-mlocation)+moment)-(x(2)*(support2... % Create
s and plots the line from the end
-mlocation)+moment+x(2)*(mlocation-endlocation)))/(mlocation... % of the
distributed load to the moment
-endlocation);
nn=endlocation:mlocation;
mm=slope2*nn+(x(2)*(support2-mlocation)+moment+x(2)*(mlocation...
-endlocation)+abs(slope2)*endlocation);
plot(nn,mm,'r')
f=x(2)*(support2-mlocation):x(2)*(support2-mlocation)+moment; % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
nn=startlocation:plocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2; % start
of the distributed load to the point load
plot(nn,mm,'r')
tt=plocation:endlocation; % Create
s and plots the parabola from the
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % point
load to the end of the distributed load
*(tt-plocation);
plot(tt,zz,'r')
slope2=((x(2)*(support2-mlocation)-moment)-(x(2)*(support2... % Create
s and plots the line from the end
-mlocation)-moment+x(2)*(mlocation-endlocation)))/(mlocation... % of the
distributed load to the moment
-endlocation);
nn=endlocation:mlocation;
mm=slope2*nn+(x(2)*(support2-mlocation)-moment+x(2)*(mlocation...
-endlocation)+abs(slope2)*endlocation);
plot(nn,mm,'r')
f=x(2)*(support2-mlocation)-moment:x(2)*(support2-mlocation); % Create
s and plots the line for the moment
s=0*f+mlocation;
plot(s,f,'r')

end % End fo
r "if signofmoment = 1"
slope3=(0-x(2)*(support2-mlocation))/(support2-mlocation); % Create
s and plots the line from the moment
pp=mlocation:support2; % to the
second support
qq=slope3*pp+(x(2)*(support2-mlocation)+abs(slope3)*mlocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if mlocation >= endlocation"

% The equations for the moment diagrams if the moment is in the location plocati
on < mlocation < endlocation
if mlocation>plocation && mlocation<endlocation
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
if signofmoment==1
d=startlocation:plocation; % Create
s the plots the parabola from the
ss=x(1)*d-(distributedload/2)*(d-startlocation).^2; % start
of the distributed load to the point load
plot(d,ss,'r')
tt=plocation:mlocation; % Create
s and plots the parabola from
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % the po
int load to the moment
*(tt-plocation);
plot(tt,zz,'r')
f=x(1)*mlocation-(distributedload/2)*(mlocation... % Create
s and plots the line for the moment
-startlocation)^2-pload*(mlocation-plocation)-moment:x(1)*mlocation...
-(distributedload/2)*(mlocation-startlocation)^2-pload...
*(mlocation-plocation);
s=0*f+mlocation;
plot(s,f,'r')
nn=mlocation:endlocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2-pload... % moment
to the end of the distributed load
*(nn-plocation)-moment;
plot(nn,mm,'r')

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
d=startlocation:plocation; % Create
s the plots the parabola from the
ss=x(1)*d-(distributedload/2)*(d-startlocation).^2; % start
of the distributed load to the point load
plot(d,ss,'r')
tt=plocation:mlocation; % Create
s and plots the parabola from
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-pload... % the po
int load to the moment
*(tt-plocation);
plot(tt,zz,'r')
f=x(1)*mlocation-(distributedload/2)*(mlocation... % Create
s and plots the line for the moment
-startlocation)^2-pload*(mlocation-plocation):x(1)*mlocation...
-(distributedload/2)*(mlocation-startlocation)^2-pload...
*(mlocation-plocation)+moment;
s=0*f+mlocation;
plot(s,f,'r')
nn=mlocation:endlocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2-pload... % moment
to the end of the distributed load
*(nn-plocation)+moment;
plot(nn,mm,'r')

end % End fo
r "if signofmoment = 1"
slope2=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
pp=endlocation:support2; % the di
stributed load to the second support
qq=slope2*pp+(x(2)*(support2-endlocation)+abs(slope2)*endlocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if plocation < mlocation < endlocation"

% The equations for the moment diagrams if the moment is in the location startlo
cation < mlocation < plocation
if mlocation<plocation && mlocation>startlocation
slope1=(x(1)*(startlocation-support1)-0)/(startlocation-support1); % Create
s and plots the line from the
uu=support1:startlocation; % first
support to the moment
vv=slope1*uu+0;
plot(uu,vv,'r')
if signofmoment==1
d=startlocation:mlocation; % Create
s the plots the parabola from the
ss=x(1)*d-(distributedload/2)*(d-startlocation).^2; % start
of the distributed load to the moment
plot(d,ss,'r')
tt=mlocation:plocation; % Create
s and plots the parabola from
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2-moment; % the mo
ment to the point load
plot(tt,zz,'r')
f=x(1)*mlocation-(distributedload/2)*(mlocation... % Create
s and plots the line for the moment
-startlocation)^2-moment:x(1)*mlocation-(distributedload/2)...
*(mlocation-startlocation)^2;
s=0*f+mlocation;
plot(s,f,'r')
nn=plocation:endlocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2-pload... % point
load to the end of the distributed load
*(nn-plocation)-moment;
plot(nn,mm,'r')

elseif signofmoment==-1 % Else f


or "if signofmoment = 1"
d=startlocation:mlocation; % Create
s the plots the parabola from the
ss=x(1)*d-(distributedload/2)*(d-startlocation).^2; % start
of the distributed load to the moment
plot(d,ss,'r')
tt=mlocation:plocation; % Create
s and plots the parabola from
zz=x(1)*tt-(distributedload/2)*(tt-startlocation).^2+moment; % the mo
ment to the point load
plot(tt,zz,'r')
f=x(1)*mlocation-(distributedload/2)*(mlocation... % Create
s and plots the line for the moment
-startlocation)^2:x(1)*mlocation-(distributedload/2)...
*(mlocation-startlocation)^2+moment;
s=0*f+mlocation;
plot(s,f,'r')
nn=plocation:endlocation; % Create
s and plots the parabola from the
mm=x(1)*nn-(distributedload/2)*(nn-startlocation).^2-pload... % point
load to the end of the distributed load
*(nn-plocation)+moment;
plot(nn,mm,'r')

end % End fo
r "if signofmoment = 1"
slope2=(0-x(2)*(support2-endlocation))/(support2-endlocation); % Create
s and plots the line from the end of
pp=endlocation:support2; % the di
stributed load to the second support
qq=slope2*pp+(x(2)*(support2-endlocation)+abs(slope2)*endlocation);
plot(pp,qq,'r')
hold off;

end % End fo
r "if startlocation < mlocation < plocation
end % End fo
r "if plocation < endlocation & plocation > startlocation"
end
disp('
')
disp('The blue line is for the shear force diagram and the red line is for the m
oment diagram.')
fprintf('The reaction forces are %10.3f and %10.3f\n',x(1),x(2))

Vous aimerez peut-être aussi