calculate shear force diagram and bending moment diagram for indetermined beam in matlab
main.m
% Define the span of the beam and the support locationsL = 5; % Span of the beama = 2; % Distance of the left support from the left end of the beamb = 4; % Distance of the right support from the left end of the beamP = 10; % Applied load at the center of the beam% Calculate the reactions at the supportsRb = P*(b/L); % Reaction at the left supportRa = P - Rb; % Reaction at the right support% Distance vector along the beamx = linspace(0, L, 1000);
% Calculate shear force (V) and bending moment (M) along the beamV = zeros(size(x));
M = zeros(size(x));
fori = 1:length(x)
if x(i) <= a
V(i) = Ra;
M(i) = Ra*x(i);
elseif x(i) <= b
V(i) = Ra - P;
M(i) = Ra*x(i) - P*(x(i) - a);
else V(i) = Ra - P;
M(i) = Ra*x(i) - P*(x(i) - a);
endend% Plot the shear force diagramfigure;
plot(x, V, 'b', 'LineWidth', 2);
xlabel('Beam Length (m)');
ylabel('Shear Force (kN)');
title('Shear Force Diagram');
% Plot the bending moment diagramfigure;
plot(x, M, 'r', 'LineWidth', 2);
xlabel('Beam Length (m)');
ylabel('Bending Moment (kNm)');
title('Bending Moment Diagram');