I am having problems evaluating the symbolic expressions for the reactions in a beam problem.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Subject: Problems evaluating symbolic expressions for reactions in a beam problem
I am having problems evaluating the symbolic expressions for the reactions in a beam problem. I have written the following code:
% Constants
L = 23; % Length of the beam
a = 4; % Distance a
w0 = 100; % Load magnitude - maximum distributed load
w = @(x) w0.*(1 - (4.*x/L) + 3.*(x./L).^2);
%a) Location of load change direction
syms x
x0_method1 = solve(w(x) == 0, x);
fprintf("The load changes its direction at x = %.2f m\n", x0_method1(1));
%b) Reactions at A, B, D
syms R_A R_D R_B x
eq1 = R_A + R_D + R_B - int(w(x), x, 0, L) == 0; % Sum of vertical forces
eq2 = R_D * a - int(w(x), x, 0, a) == 0; % Moment equation about A
V = R_A * mac(x, 0, 1) + R_D * mac(x, L - a, 1) + int(w(x), x, 0, L);
M = R_A * mac(x, 0, 1) + R_D * mac(x, L - a, 1) + int(w(x) * x, x, 0, L) - R_D * a;
% boundary conditions
eq3 = subs(V, x, 0) == 0; % V(0) = 0 (at the fixed end)
eq4 = subs(M, x, 0) == 0; % M(0) = 0 (no moment at A)
% Solve the system of equations for reactions R_A, R_D, and R_B
sol = solve([eq1, eq2, eq3, eq4], [R_A, R_D, R_B]);
% Evaluate the reactions
R_A_val = eval(sol.R_A);
R_D_val = eval(sol.R_D);
R_B_val = eval(sol.R_B);
% Print the results
fprintf("Reactions:\n R_A = %.2f N\n R_D = %.2f N\n R_B = %.2f N\n",R_A_val,R_D_val,R_B_val);
function egg = mac(x, d, n)
k = heaviside(x - d);
if k == 0
egg = 0;
else
egg = (x - d)^n;
end
end
When I run this code, I get the following output:
The load changes its direction at x = 7.67 m
Reactions:
R_A = N
R_D = N
R_B = N
As you can see, the reactions are not being evaluated correctly. I have tried simplifying the symbolic expressions before evaluating them, but this does not work.
I am using MATLAB R2023a livescript on a Windows 11 machine.
Please help me resolve this issue.
Additional information:
* I have tried running the code in a new script file, but this does not fix the problem.
* I have also tried clearing the MATLAB workspace before running the code, but this does not work either.
* I am using the `eval()` function to evaluate the symbolic expressions for the reactions because the `simplify()` function does not work.
I hope this information is helpful. Thank you for your time and assistance.
2 Commenti
Torsten
il 15 Set 2023
Modificato: Torsten
il 15 Set 2023
You cannot solve 4 equations for 3 unknowns.
And see how the equations look like:
% Constants
L = 23; % Length of the beam
a = 4; % Distance a
w0 = 100; % Load magnitude - maximum distributed load
w = @(x) w0.*(1 - (4.*x/L) + 3.*(x./L).^2);
%a) Location of load change direction
syms x
x0_method1 = solve(w(x) == 0, x);
fprintf("The load changes its direction at x = %.2f m\n", x0_method1(1));
%b) Reactions at A, B, D
syms R_A R_D R_B x
eq1 = R_A + R_D + R_B - int(w(x), x, 0, L) == 0% Sum of vertical forces
eq2 = R_D * a - int(w(x), x, 0, a) == 0 % Moment equation about A
V = R_A * mac(x, 0, 1) + R_D * mac(x, L - a, 1) + int(w(x), x, 0, L);
M = R_A * mac(x, 0, 1) + R_D * mac(x, L - a, 1) + int(w(x) * x, x, 0, L) - R_D * a;
% boundary conditions
eq3 = subs(V, x, 0) == 0 % V(0) = 0 (at the fixed end)
eq4 = subs(M, x, 0) == 0 % M(0) = 0 (no moment at A)
% Solve the system of equations for reactions R_A, R_D, and R_B
%sol = solve([eq1, eq2, eq3, eq4], [R_A, R_D, R_B]);
% Evaluate the reactions
%R_A_val = eval(sol.R_A);
%R_D_val = eval(sol.R_D);
%R_B_val = eval(sol.R_B);
% Print the results
%fprintf("Reactions:\n R_A = %.2f N\n R_D = %.2f N\n R_B = %.2f N\n",R_A_val,R_D_val,R_B_val);
function egg = mac(x, d, n)
k = heaviside(x - d);
if k == 0
egg = 0;
else
egg = (x - d)^n;
end
end
Star Strider
il 15 Set 2023
‘As you can see, the reactions are not being evaluated correctly.’
They are not being evaluated at all. The ‘sol’ variable has three empty solutions.
It would help if you state the problem you want to solve, and the equations you intend to use, including conditions on them.
Risposte (1)
Ishu
il 28 Set 2023
Modificato: Ishu
il 28 Set 2023
Hi Nickilese,
I understand that you are trying to evaluate symbolic equations with the "solve" function and you are getting an empty solution.
As there are 4 equations and 3 variables (more equations than unknowns), it is not possible to find a unique solution for the system of equations.
Additionally, if you look at the equations "eq2", "eq3" and "eq4", these 3 equations only contain the "R_D" variable. In order to get a solution of your system, you can use only one equation from "eq2", "eq3", and "eq4" along with "eq1" according to the needs.
sol = solve([eq1, eq2], [R_A, R_D, R_B]);
As neither equation contains "V_B", this system will assume "R_B" to be zero.
If you want a solution for a range of "R_B", then you can modify the code as:
sol = solve([eq1, eq2], [R_A, R_D, R_B], "ReturnConditions", true);
For more information on the "solve" function you can refer to the MathWorks documentation attached below:
Hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!