the loading function w(x) for the following beam in matlab

Assuming that you have the necessary input data for the beam such as length, the modulus of elasticity, and the moment of inertia, you can calculate the loading function w(x) using the following steps:

  1. Define the coordinates along the beam axis in a vector:
main.m
x = linspace(0, L, N);
23 chars
2 lines

where L is the length of the beam and N is the number of points to define along the beam axis.

  1. Define the distributed load function q(x) and any point loads P applied to the beam:
main.m
q = ... % define the distributed load function of x
P = [P1, P2, ...]; % vector of point loads
95 chars
3 lines
  1. Solve the differential equation that describes the deflection of the beam under the applied loads:
main.m
i = (1:N)';
A = sin(i.*pi/L);
B = (L./(i.*pi)).*(1-cos(i.*pi));
C = (2./(i.*pi)).*(1-cos(i.*pi));
D = (2./(i.*pi).^2).*(1-cos(i.*pi)-i.*pi.*sin(i.*pi));

w = (q.*L^4./(E*I)).*(A.*(h/2)+B.*(theta/2)+C.*(w/2)+D);
211 chars
8 lines

where E is the modulus of elasticity, I is the moment of inertia, h is the distance from the neutral axis to the top or bottom of the beam, and theta is the rotation of the beam.

  1. Add the contribution from the point loads to the deflection function:
main.m
for i = 1:length(P)
    w = w + (P(i)/(6*E*I))*((x-L).^3).*((x>=L)-(x>=0));
end
80 chars
4 lines

The resulting w vector gives the deflection of the beam at the specified coordinates x.

gistlibby LogSnag