how do I build the a beam deflection graph ?

์กฐํšŒ ์ˆ˜: 62 (์ตœ๊ทผ 30์ผ)
Netanel Malihi
Netanel Malihi 2021๋…„ 11์›” 15์ผ
๋‹ต๋ณ€: NODIRABDUSHAKHIDOV 2024๋…„ 1์›” 26์ผ
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.
The code that i wrote gives me an empty graph
  ๋Œ“๊ธ€ ์ˆ˜: 4
Netanel Malihi
Netanel Malihi 2021๋…„ 11์›” 15์ผ
Of course excuse me
VBBV
VBBV 2021๋…„ 11์›” 15์ผ
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.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

๋‹ต๋ณ€ (3๊ฐœ)

KSSV
KSSV 2021๋…„ 11์›” 15์ผ
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
Netanel Malihi
Netanel Malihi 2021๋…„ 11์›” 15์ผ
thanks, how do i code the range condition: 100โˆ™ 10^6 mm^4 โ‰ค I โ‰ค 450โˆ™10^6 mm^4 in the graph?
KSSV
KSSV 2021๋…„ 11์›” 15์ผ
Read about axis and inequalitties i.e. <, >

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.


Talal
Talal 2023๋…„ 4์›” 17์ผ
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

NODIRABDUSHAKHIDOV
NODIRABDUSHAKHIDOV 2024๋…„ 1์›” 26์ผ
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

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Programming์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์ œํ’ˆ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by