how do I build the a beam deflection graph ?
17 views (last 30 days)
Show older comments
How do you do?
I was wondering if someone could help me with a problem I have been given. It is about deflection of beams in a course in college called numerical analysis.
Given: 𝑞0 = 1𝑁𝑚𝑚, E = 140MPa, L = 1000mm, v = -0.7mm.
1.Draw the x in front of I for 100∙ 10^6 mm^4 ≤ I ≤ 450∙10^6 mm^4. What conclusion can be physically deduced from the graph?
2. Find the value of I for which the beam does not decrease to the value given above.
Write down how you chose an initial guess.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/800474/image.png)
The code that i wrote gives me an empty graph
4 Comments
VBBV
on 15 Nov 2021
The code that you wrote in snapshot (image) is not same as whats posted in OP.
Did you try with code in your OP ?
Note that reason why you dont see the plot is that you're trying to plot against one point in x vector. vs I
when the for loop is completed, value of x is just one point instead of vector as specified in OP.
Answers (3)
KSSV
on 15 Nov 2021
q0 = 1 ;
E = 140 ;
L = 1000 ;
v = -0.7 ;
beamDeflection(v,q0,L,E) ;
function beamDeflection(v,q0,L,E)
%for x=0:100:1000
%I = -(q0*L)/(3*pi^4*E*v)*(48*L^3*cos((pi*x)/(2*L))-48*L^3+3*pi^3*L*x^2-pi^3*x^3)
%end
%plot(x,I)
x = 0:1:1000 ;
I = -(q0*L)/(3*pi^4*E*v)*(48*L^3*cos((pi*x)/(2*L))-48*L^3+3*pi^3*L*x.^2-pi^3*x.^3) ;
plot(x,I)
end
2 Comments
Talal
on 17 Apr 2023
function [X, y_true, y_num, error] = beam_deflection(x_initial,x_step, x_end,E, I, M)
% Calculates beam deflection using analytical and numerical integration methods
% Inputs:
% x_initial: starting value for x
% x_step: step size for x
% x_end: ending value for x
% E: modulus of elasticity
% I: moment of inertia
% M: function handle for moment as a function of x
% Outputs:
% X: array of x values
% y_true: array of true deflection values
% y_num: array of numerical deflection values
% error: array of errors between true and numerical deflection values
% Create array of x values
X = x_initial:x_step:x_end;
% Initialize arrays for y_true, y_num, and error
y_true = zeros(1, length(X));
y_num = zeros(1, length(X));
error = zeros(1, length(X));
% Calculate y_true for each x value using analytical integration
for i = 1:length(X)
x = X(i);
y_true(i) = integral(@(x) M(x)/(E*I), 0, x);
end
% Calculate y_num for each x value using numerical integration
for i = 2:length(X)
x = X(i);
x_prev = X(i-1);
theta_prev = M(x_prev)/(E*I);
theta = M(x)/(E*I);
y_num(i) = y_num(i-1) + ((x - x_prev)/2)*(theta +theta_prev);
end
% Calculate error for each x value
error = y_true - y_num;
end
% Input variables
x_initial = 0;
x_step = 0.01;
x_end = 5;
E = 200e9; % Pa
I = 8.333e-6; % m^4
wo = 1000; % N/m
% Moment as a function of x
M = @(x) (wo*x^2*(10-x)^2)/120;
% Call beam_deflection function
[X, y_true, y_num, error] = beam_deflection(x_initial, x_step, x_end, E, I, M);
% Plot results
figure
plot(X, y_true, 'r', X, y_num, 'b')
title('Beam Deflection')
xlabel('x (m)')
ylabel('y (m)')
legend('Analytical', 'Numerical')
I am not getting the plots, could anyone resolve this issue and rectidy the error
0 Comments
NODIRABDUSHAKHIDOV
on 26 Jan 2024
check this out. Hope it solves your problem.
clear all
% Input variables
x_initial = 0;
x_step = 0.01;
x_end = 5;
E = 200e9; % Pa
I = 8.333e-6; % m^4
wo = 1000; % N/m
% Moment as a function of x
M = @(x) (wo*x.^2.*(10-x).^2)/120;
% Call beam_deflection function
[X, y_true, y_num, error] = beam_deflection(x_initial, x_step, x_end, E, I, M);
% Plot results
figure
plot(X, y_true, 'r', X, y_num, 'b');
xlabel('x');
ylabel('Deflection');
legend('True deflection', 'Numerical deflection');
title('Beam Deflection');
function [X, y_true, y_num, error] = beam_deflection(x_initial, x_step, x_end, E, I, M)
% Calculates beam deflection using analytical and numerical integration methods
% Inputs:
% x_initial: starting value for x
% x_step: step size for x
% x_end: ending value for x
% E: modulus of elasticity
% I: moment of inertia
% M: function handle for moment as a function of x
% Outputs:
% X: array of x values
% y_true: array of true deflection values
% y_num: array of numerical deflection values
% error: array of errors between true and numerical deflection values
% Create array of x values
X = x_initial:x_step:x_end;
% Initialize arrays for y_true, y_num, and error
y_true = zeros(1, length(X));
y_num = zeros(1, length(X));
error = zeros(1, length(X));
% Calculate y_true for each x value using analytical integration
for i = 1:length(X)
x = X(i);
y_true(i) = integral(@(x) M(x)/(E*I), 0, x);
end
% Calculate y_num for each x value using numerical integration
for i = 2:length(X)
x = X(i);
x_prev = X(i-1);
theta_prev = M(x_prev)/(E*I);
theta = M(x)/(E*I);
y_num(i) = y_num(i-1) + ((x - x_prev)/2)*(theta + theta_prev);
end
% Calculate error for each x value
error = abs(y_true - y_num); % Calculate absolute difference
end
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!