Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MatLab Beam Shear force diagram and Bending Moment Diagram

Status
Not open for further replies.

Borys147

Civil/Environmental
Mar 7, 2016
2
0
0
IE
Hi all,

My final year civil engineering assignment requires me to use matlab and create a shear force and bending moment diagrams for a simply supported beam. The only problem we can't coded it properly. The question is below

"You are required to create a script file in Matlab capable of calculating the key values and plotting a
load diagram; shear force diagram and a bending moment diagram for a simply supported beam
subjected to any combination of a uniformly distributed load along its entire length and up to 2 point
loads within the span.
The user should be able to input the beam span, the value of the UDL, the value and position of each
of the point loads. The user may also input the no. of intervals along the beam or the size of the
intervals along the beam for calculating the shear force and bending moment values."


That's the code i managed to write so far, but it does not work as it should,

PLEASE HELP !!!!!!!!!!!!!!!!!!!!!!!!!


clear all; clc

%Step 1 - User Input%
Span = 10;
UDL = 5;
P1 = 15;
PL1 = 2;
P2 = 10;
PL2 = 6

c = Span-PL1

%Step - Calculate Beam end Reactions
R1 = ((P1*(Span-PL1))+(P2*(Span-PL2))+(UDL*Span*(Span/2)))/Span %Left Support Reaction
R2 = ((P1*PL1)+(P2*PL2)+(UDL*Span*(Span/2)))/Span %Right Support Reaction

%Discretization of x axis

n = 20; %Number of discretization of x-axis.
delta_x=Span/n; %Increment for discretization of x-axis.
x = (0:delta_x:Span); %Generate column array for x-axis.

SF = zeros(size(x,1),1); %Shear force function of x.
BM = zeros(size(x,1),1); %Bending Moment function of x.



for ii=1:n+1
%First portion of the beam, 0<x<
if x(ii)<=PL1;
SF(ii) = R1-(UDL*delta_x*(ii-1));
BM(ii) = R1*x(ii);
SFO(ii)=0;
elseif x(ii)>=Span&&x(ii)<PL1;
SF(ii) = R1-(UDL*PL1)-P1;
SFO(ii) = 0;
elseif x(ii)>PL1;
SF(ii) = R1-(UDL*delta_x*(ii-1))-P1
SFO(ii) = 0;
elseif x(ii)>PL1;
SF(ii) = R1-(UDL*delta_x*(ii-1))-P1
SFO(ii) = 0;
end
end





%SHEAR FORCE CALCULATION

subplot(3,1,1)
plot(x,UDL,'b.-')
grid
title('Span of the Beam')
xlabel('Span (m)') %x-axis label
ylabel('UDL (kN/m)') %y-axis label

subplot(3,1,2)
plot(x,SF,'m',x,SFO,'b','linewidth',1.5)
grid
title('Shear Force Diagram')
xlabel('Span (m)') %x-axis label
ylabel('Shear Force (kN)') %y-axis label

subplot(3,1,3)
plot(x,BM,'m',x,BMO,'b','linewidth',1.5)
grid
title('Bending Moment Diagram')
xlabel('Span (m)') %x-axis label
ylabel('Bending Moment (kN-m)') %y-axis label


 
Replies continue below

Recommended for you

Not a MatLab guy - practicing engineer, so Mathcad was always my choice.

But what is the point of the exercise? To show proficiency in MatLab or to show that you understand the basic theory behind beam bending?

I think I understand the code as written, except of the "discretization of the X-axis" part. Are you arbitrarily dividing the beam into 20 segments? Why? Is that necessary to report forces at each segment?

I think I'd look there first. Are you sure you're able to correctly compute the internal beam forces in those locations the way you have it set up? Because that seems like a lot of work to so something a bit more simply. If it were me, I think I'd have it report the forces at each location of a point-load, and connect the force diagram curves between them. Is "Pn" the magnitude and "PLn" the location of the point loads? Just compute the forces at those points; the rest is simple algebra.


"No one is completely useless. He can always serve as a bad example." --My Dad ca. 1975
 
Status
Not open for further replies.
Back
Top