clc;
disp('Simply Supported Beam with 2 Point Loads');
%% Data input section
Length = input('Length of beam in meters = ');
% Input parameters for the first point load
W1 = input('Magnitude of the first Point Load in kN = ');
a1 = input('Location of the first Point Load from the left end of the beam in meters =');
% Input parameters for the second point load
W2 = input('Magnitude of the second Point Load in kN = ');
a2 = input('Location of the second Point Load from the left end of the beam in meters= ');
%%
%
% for x = 1:10
% disp(x)
% end
%
%% Calculation
R1 = (W1*a2 + W2*a1) / Length; % Left Support Reaction.
R2 = W1 + W2 - R1; % Right Support Reaction.
% Discretization of x axis.
n = 1000; % Number of discretization of x axis.
delta_x = Length/n; % Increment for discretization of x axis.
x = (0:delta_x:Length)'; % Generate column array for x-axis.
V = zeros(size(x)); % Initialize V as zeros
M = zeros(size(x)); % Initialize M as zeros
for i = 1:n+1
% Calculate V and M for each segment of the beam
% For the segment before the first point load
if x(i) < a1
V(i) = R1;
M(i) = R1 * x(i);
end
% For the segment between the first and second point loads
if x(i) >= a1 && x(i) <= a2
V(i) = R1 - W1;
M(i) = R1 * x(i) - W1 * (x(i) - a1);
end
% For the segment after the second point load
if x(i) > a2
V(i) = R1 - W1 - W2;
M(i) = R1 * x(i) - W1 * (x(i) - a1) - W2 * (x(i) - a2);
end
end
Mmax = max(M);
disp(' '); % Just to keep some gap between output Empty display
disp(' ');
disp(['Left support Reaction in kN is ' num2str(R1)])
disp(['Right support Reaction in kN is ' num2str(R2)])
disp(['Maximum bending moment in is ' num2str(max(M)) ' kN-m'])
% Plotting of diagrams
figure
subplot(2,1,1);
plot(x, V, 'r','linewidth',1.5);
grid on;
title('Shear Force Diagram','fontsize',16)
subplot(2,1,2);
plot(x, M, 'k','linewidth',1.5);
grid on;
title('Bending Moment Diagram','fontsize',16)
Cite As
Adeeb Raza (2025). gandu (https://se.mathworks.com/matlabcentral/fileexchange/136394-gandu), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2023b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
