# How do you solve for constants in a system of equations?

1 view (last 30 days)
Daniel Wilkinson on 29 Oct 2021
Commented: Sam Chak on 30 Oct 2021
Good Morning,
I'm trying to determine how to solve for constants in a system of equations with specified conditions. Please see the below forumlaic explanation. I've explored using "solve", but am unsure how to set the condition values as seed for the solution. FYI, this is for solving a cantilever beam deflection with varying cross section (changing area moment of inertia). This is a simplistic representation of the problem by solving for only two distinct sections, but in practice there would be many more depending on the considered sampling length.
Thank you for any feedback or hints for functions to explore.
P, L, E1 & E2 are all known values
s1=(P/(2*E*I1))*(2*L*x-x^2)+C1*x;
s2=(P/(2*E*I2))*(2*L*x-x^2)+C2*x;
v1=(P/(6*E*I1))*(3*L*x^2-x^3)+C1*x+C3;
v2=(P/(6*E*I2))*(3*L*x^2-x^3)+C2*x+C4;
at x=0 s1=0 and v1=0
at x=L/2 s1=s2, and v1=v2
Sam Chak on 29 Oct 2021
What is when ? If you can get , then you can find all of them in this order , , , .
, are found when , while , can be found when .

Paul on 30 Oct 2021
syms P L E1 E2 % are all known values, E1 and E2 not used?
syms I1 I2 E % also known values?
syms C1 C2 C3 C4
syms x
s1(x) = (P/(2*E*I1))*(2*L*x-x^2)+C1*x;
s2(x) = (P/(2*E*I2))*(2*L*x-x^2)+C2*x;
v1(x) = (P/(6*E*I1))*(3*L*x^2-x^3)+C1*x+C3;
v2(x) = (P/(6*E*I2))*(3*L*x^2-x^3)+C2*x+C4;
% at x=0 s1=0 and v1=0
eqn1 = s1(0) == 0;
eqn2 = v1(0) == 0;
% at x=L/2 s1=s2, and v1=v2
eqn3 = s1(L/2) == s2(L/2);
eqn4 = v1(L/2) == v2(L/2);
sol = solve([eqn1 eqn2 eqn3 eqn4],[C1 C2 C3 C4],'ReturnConditions',true)
sol = struct with fields:
C1: (3*I1*L*P - 3*I2*L*P + 4*E*I1*I2*z)/(4*E*I1*I2) C2: z C3: 0 C4: ((- 5*P*L^3 + 18*P*L^2)*(I1 - I2))/(48*E*I1*I2) parameters: z conditions: L ~= 0
[sol.C1 sol.C2 sol.C3 sol.C4]
ans =
It looks like C3 must be zero, C2 can be anything, and C1 and C4 have the values shown, as long as
sol.conditions
ans =
Sam Chak on 30 Oct 2021
Hi @Paul,
Thank you for the analysis. I learned something new on using the subs function to validate the results.

R2021a

### Community Treasure Hunt

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

Start Hunting!