I'm new to Matlab (R2017b). I'm triying to solve a differential equation system with this script:
clear;
syms k x1(t) x2(t) M b f t;
dx2_1 =diff(x2,t);
dx2_2 =diff(x2,t,t);
dx1_1 =diff(x1,t);
dx1_2 =diff(x1,t,t);
eq1 = k*(x1 - x2) - b*dx2_1 == M*dx2_2;
eq2 = k*(x1-x2) == f;
cond = [x1(0)==0; x2(0)==0; dx2_1(0)==0];
s = dsolve([eq1; eq2],cond);
And i'm getting this error:
Warning: Number of equations greater than number of indeterminates. Trying heuristics to reduce to square system.
> In symengine
In mupadengine/evalin (line 123)
In mupadengine/feval (line 182)
In dsolve>mupadDsolve (line 337)
In dsolve (line 194)
In Untitled (line 11)
Error using mupadengine/feval (line 187)
Unable to reduce to square system because the number of equations differs from the number of indeterminates.
Error in dsolve>mupadDsolve (line 337)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 194)
sol = mupadDsolve(args, options);
Error in Untitled (line 11)
s = dsolve([eq1; eq2],cond);
I don't understand what is wrong. I understand that I have two unknowns functions x1 and x2 and two equations, so it can be solved.
I've already solve this system manually and also with this script:
clear;
syms k x1(t) x2(t) s M b f(t) t;
dx2_1 =diff(x2,t);
dx2_2 =diff(x2,t,t);
dx1_1 =diff(x1,t);
dx1_2 =diff(x1,t,t);
eq1 = k*(x1 - x2) - b*dx2_1 == M*dx2_2;
eq2 = k*(x1-x2) == f;
syms X1 X2 F
EQ1 = laplace(eq1,t,s)
EQ2 = laplace(eq2,t,s)
EQ1= subs(EQ1,[laplace(x1(t), t, s) laplace(x2(t), t, s) laplace(f(t), t, s) subs(diff(x2(t), t), t, 0) x1(0) x2(0)], [X1 X2 F 0 0 0]);
EQ2= subs(EQ2,[laplace(x1(t), t, s) laplace(x2(t), t, s) laplace(f(t), t, s) x1(0) x2(0)], [X1 X2 F 0 0]);
sol=solve([EQ1;EQ2],[X1,X2]);
sol.X1
sol.X2
The output is:
ans =
(F*(M*s^2 + b*s + k))/(k*(M*s^2 + b*s))
ans =
F/(M*s^2 + b*s)
What is wrong with my first try? I also try to replace all symbolic variables with numbers but i have the same error.