MATLAB: 1D Linear Elasticity Equivalent Stiffness Solution not being solved (6 equations and 6 vars)

definitionelasticelasticityequationslinearMATLABordinarysolutionstiffnesssyntax

Hey guys, I am unable to make my program get a result of w as a function of EI and L
syms w x EI A B C D L
x0=0;
eqns = [EI*diff(w,3)==heaviside(x-x0)+A, EI*diff(w,2)==heaviside(x-x0)*(x-x0)+A*x+B, EI*diff(w)==heaviside(x-x0)*(x-x0)^2/2+A*x^2/2+B*x+C, EI*w==heaviside(x-x0)*(x-x0)^3/6+A*x^3/6+B*x^2/2+C*x+D, w(x==L/2)==0, diff(w(x==-L/2))==0];
ctes = [A B C D];
[A, B, C, D]=solve(eqns, ctes);
w(x==0)
This is what I've coded. As you can see it is 4 equations and 2 boundary conditions (The 2 last ones) I want it to solve the 4 constants A, B, C and D, so I get the full result of the function w(x) with those Constants solved and then finally evaluate w for x=0 (in this case). But it is giving me this result:
ans =
[ empty sym ]
I am pretty sure it is something about syntax in the equations definition, but I can't find it. Could you give it a look guys? I would really appreciate. This example should give the following solution w(x=0) = L^3/(192*EI)
Thank you very much!

Best Answer

These are differential equations, a boundary value problem.
We use dsolve to solve it. For example, a simple example is:
syms x(t)
Eq = diff(x,t,2) == 1 + t;
dsolve(Eq,x(0) == 0,x(1) == 2)
ans =
(t*(t^2 + 3*t + 8))/6
Now, what happens when you just throw it at solve?
solve(Eq,x(0) == 0,x(1) == 2)
Warning: Unable to find explicit solution. For options, see help.
> In sym/solve (line 317)
ans =
Empty sym: 0-by-1
Finally, even though you used solve to try to find a solution, that last line, w(x==0) does not do what you think it does. In fact, in your code, even though you tried to return A,B,C,D, those values are not magically inserted into the relationship for w.
Oh, this is not how you create a boundary condition:
w(x==L/2)==0
Again, that does NOT set x to a value of L/2, and then substitute it into w. Instead, you would formulate that boundary condition for dsolve as
w(L/2) == 0
So, first, solve the ODE as a differential equation. Use dsolve.