简体   繁体   中英

Error when solving symbolic system of ODEs using dsolve

I have been trying to use the command dsolve in Matlab to solve a set of ODEs, but I am getting these errors:

Error in dsolve>mupadDsolve (line 332) T = feval(symengine,'symobj::dsolve',sys,x,options);

Error in dsolve (line 193) sol = mupadDsolve(args, options);

Below is the code if someone wants to take a look at it:

syms t b1 b2 k1 k2;
A=0.5;
m1=3;m2=4;w=6;
y=A*sin(w*t);
xt=dsolve('m1*D2x1+b1*((Dx1)-Dy)+k1*(x1-y)+b2*((Dx1)-(Dx2))+k2*(x1-x2)=0','m2*D2x2+b2*((Dx2)-(Dx1))+k2*(x2-   x1)=0','x1(0)=0','Dx1(0)=0','x2(0)=0','Dx2(0)=0');

Could someone please help me with that?

Thank you all very much

Quoting from the dsolve documentation :

The names of symbolic variables used in differential equations should not contain the letter D because dsolve assumes that D is a differential operator and any character immediately following D is a dependent variable.

As such, the Dy in your argument string is telling dsolve there is some unknown function y to solve for but without an initial condition (in addition to it being an indeterminant system).

To fix the issue, define the derivative a y outside dsolve and assign it to a variable without D :

syms t b1 b2 k1 k2;
A=0.5;
m1=3;m2=4;w=6;
y=A*sin(w*t);
dydt = diff(y,1);
xt=dsolve('m1*D2x1+b1*((Dx1)-dydt)+k1*(x1-y)+b2*((Dx1)-(Dx2))+k2*(x1-x2)=0','m2*D2x2+b2*((Dx2)-(Dx1))+k2*(x2-x1)=0','x1(0)=0','Dx1(0)=0','x2(0)=0','Dx2(0)=0');

This version of the code runs for me ... and runs and runs. While it does run, I think more constants need to be defined in order for an answer to be generated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM