index = (Positions <= PointLoads(k, 2));
ShearForce = sum(PointLoads(index, 1));
%ShearForce for DistributedLoadsLoads
D = DistributedLoads; % Nicer name
maxD = max(D(:, 2:3), [], 1);
minD = min(D(:, 2:3), [], 1);
for k = 1:size(D,1)
if Positions >= maxD(k)
A = maxD(k) - minD(k);
B = (Positions < minD(k));
C = maxD(k) - Positions;
D = (and(~B, Positions <= maxD(k)));
ShearForce = ShearForce + D(k,1) .* (A .* B + C .* D);
end
end
Is "Positions" a vector? If so, are you sure that "if Positions >= maxD(k)" does, what you want?