indeterminate beam and concrete load calculate shear force diagram and bending moment diagram and deflection in matlab

main.m
% Define properties of the beam and load
L = 5; % Length of the beam
P = 10; % Load applied at the midpoint of the beam
E = 200e9; % Young's Modulus of the material
I = 4e-6; % Moment of Inertia of the beam
a = L / 2; % Distance of load from the support

% Calculate reactions at the supports
R1 = P / 2;
R2 = P / 2;

% Define x coordinates
x = 0:0.01:L;

% Calculate shear force (V) and bending moment (M) at every point x
V = zeros(size(x));
M = zeros(size(x));

for i = 1:length(x)
    if x(i) < a
        V(i) = R1;
        M(i) = R1 * x(i);
    else
        V(i) = R1 - P;
        M(i) = R1*x(i) - P*(x(i)-a);
    end
end

% Calculate deflection (delta) at every point x
delta = zeros(size(x));
for i = 1:length(x)
    delta(i) = -P*a*x(i)/(6*E*I)*(L^2-x(i)^2) + R1*x(i)^2/(2*E*I) - M(i)/(E*I);
end

% Plot the shear force diagram
figure;
plot(x, V, 'b', 'LineWidth', 2);
xlabel('Position (m)');
ylabel('Shear Force (N)');
title('Shear Force Diagram');

% Plot the bending moment diagram
figure;
plot(x, M, 'r', 'LineWidth', 2);
xlabel('Position (m)');
ylabel('Bending Moment (Nm)');
title('Bending Moment Diagram');

% Plot the deflection diagram
figure;
plot(x, delta, 'g', 'LineWidth', 2);
xlabel('Position (m)');
ylabel('Deflection (m)');
title('Deflection Diagram');
1277 chars
55 lines

gistlibby LogSnag