Hi @Benjamin,
You mentioned in your posted form, “trying to plot the deflection of a beam under bending forces”
Please see my response to your comment below.
To illustrate it with example code snippet, define beam properties by setting the length of the beam L, Young's modulus of the beam material E, moment of inertia of the beam cross-section I, and the distributed load on the beam w. Then, create a vector of positions by creating a vector x representing positions along the beam using linspace from 0 to L with 1000 points, then deflection at each position is calculated using the formula for beam deflection under bending forces. Finally plot the deflection profile using plot, labeling the axes, adding a title, and displaying a grid for better visualization. Please see attached plot.
% Define beam properties
L = 5; % Length of the beam (in meters)
E = 2.1e11; % Young's modulus of the beam material (in Pascals)
I = 4.5e-5; % Moment of inertia of the beam cross-section (in meters^4)
w = 1000; % Distributed load on the beam (in Newtons per meter)
% Create a vector of positions along the beam
x = linspace(0, L, 1000);
% Calculate the deflection at each position
deflection = (w/(24*E*I)) * x.^2 .* (x.^2 - 4*L*x + 6*L^2);
% Plot the deflection profile
plot(x, deflection);
xlabel('Position along the beam (m)');
ylabel('Deflection (m)');
title('Beam Deflection Profile');
grid on;
Hope this will help resolve your problem now.