0

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

Mostafiz
  • 7,243
  • 3
  • 28
  • 42
  • There should be more of the error message. What is the full error? Also, please fix the code formatting in your question. – Andras Deak -- Слава Україні Apr 04 '16 at 22:21
  • Thanks Andras error is: 'Error using mupadengine/feval (line 163) Invalid initial conditions. Error in dsolve>mupadDsolve (line 332) T = feval(symengine,'symobj::dsolve',sys,x,options); Error in dsolve (line 193) sol = mupadDsolve(args, options);' – Taiwaninja Apr 04 '16 at 22:39
  • Please put this information in your question, and fix the overall formatting problems. People will only start to want to help you if they clearly see the problem without straining their eyes:) Myself included. – Andras Deak -- Слава Україні Apr 04 '16 at 22:42

1 Answers1

0

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.

TroyHaskin
  • 8,361
  • 3
  • 22
  • 22