dsolve() function yielding errors

Have been trying to solve the following equation for some time, but when I run the same it yields some errors which I'm unable to understand.
inits='x(0)=0,r(0)=0,s(0)=0,q(0)=0';
eqn1='40000*x-20000*s-20000*q+500*Dx-250*Ds-250*Dq+750*D2x=0';
eqn2='90000*r+30000*s-30000q+1125*Dr+375*Ds-375*Dq+1000*D2r=0';
eqn3='-20000*x+30000*r+220000*s-250*Dx+375*Dr+250*Ds+35*D2s=2000000';
eqn4='-20000*x+30000*r+220000*q-250*Dx+375*Dr+250*Dq+35*D2q=2000000';
[x,r,s,q]=dsolve('eqn1','eqn2','eqn3','eqn4',inits);
This is yielding the following error
Error using symengine (line 58)
Could not extract differential variables to solve for. Use 'solve'
or 'vpasolve' to compute the solutions of non-differential
equations.
Error in mupadengine/feval (line 155)
symengine('error',S(8:find(S=='[',1)-2));
Error in dsolve>mupadDsolve (line 325)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 186)
sol = mupadDsolve(args, options);
Error in Pitch_equation_of_motion_solve (line 6)
[x,r,s,q]=dsolve('eqn1','eqn2','eqn3','eqn4',inits);

Answers (1)

Torsten
Torsten on 5 Feb 2015
1. Define x(t),r(t),s(t),q(t) as symbolic
2. Use "==" instead of "=" in the definition of the equations
3. Use diff(x), diff(r), diff(s), diff(q) instead of Dx, Dr, Ds, Dq.
Best wishes
Torsten.

9 Comments

Nishanth
Nishanth on 6 Feb 2015
Edited: Nishanth on 6 Feb 2015
Thank you for your answer. As you suggested, I made the necessary changes & ran the script. But this too isn't working.
syms x(t) r(t) s(t) q(t) inits='x(0)=0,r(0)=0,s(0)=0,q(0)=0'; eqn1='40000*x-20000*s-20000*q+500*diff(x)-250*diff(s)-250*diff(q)+750*diff(diff(x))=0'; eqn2='90000*r+30000*s-30000q+1125*diff(r)+375*diff(s)-375*diff(q)+1000*diff(diff(r))=0'; eqn3='-20000*x+30000*r+220000*s-250*diff(x)+375*diff(r)+250*diff(s)+35*diff(diff(s))=2000000'; eqn4='-20000*x+30000*r+220000*q-250*diff(x)+375*diff(r)+250*diff(q)+35*diff(diff(q))=2000000'; [x,r,s,q]=dsolve('eqn1','eqn2','eqn3','eqn4',inits);
Is there something that I'm doing differently? Your feedback would be really helpful.
It is yielding the following error:
Error using symengine (line 58) Could not extract differential variables to solve for. Use 'solve' or 'vpasolve' to compute the solutions of non-differential equations.
Error in mupadengine/feval (line 155) symengine('error',S(8:find(S=='[',1)-2));
Error in dsolve>mupadDsolve (line 325) T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 186) sol = mupadDsolve(args, options);
You still use "=" instead of "==" in the definition of the eqn's. This is wrong.
Replace
[x,r,s,q]=dsolve('eqn1','eqn2','eqn3','eqn4',inits);
by
[x,r,s,q]=dsolve(eqn1,eqn2,eqn3,eqn4,inits);
If your code still does not work, insert the eqn's directly in the call to dsolve:
[x,r,s,q]=dsolve(40000*x-20000*s-20000*q+500*diff(x)-250*diff(s)-250*diff(q)+750*diff(diff(x))==0,90000*r+30000*s-30000q+1125*diff(r)+375*diff(s)-375*diff(q)+1000*diff(diff(r))==0,-20000*x+30000*r+220000*s-250*diff(x)+375*diff(r)+250*diff(s)+35*diff(diff(s))==2000000,-20000*x+30000*r+220000*q-250*diff(x)+375*diff(r)+250*diff(q)+35*diff(diff(q))==2000000,x(0)==0,r(0)==0,s(0)==0,q(0)==0);
Best wishes
Torsten
*Hello Mr.Tosten, Thank you for helping me out. But, even after trying out your suggestion, the problem seems to persist.
For the below input
syms x(t) r(t) s(t) q(t)
[x,r,s,q]=dsolve(40000*x-20000*s-20000*q+500*diff(x)-250*diff(s)-250*diff(q)+750*diff(diff(x))==0,90000*r+30000*s-30000q+1125*diff(r)+375*diff(s)-375*diff(q)+1000*diff(diff(r))==0,-20000*x+30000*r+220000*s-250*diff(x)+375*diff(r)+250*diff(s)+35*diff(diff(s))==2000000,-20000*x+30000*r+220000*q-250*diff(x)+375*diff(r)+250*diff(q)+35*diff(diff(q))==2000000,x(0)==0,r(0)==0,s(0)==0,q(0)==0);
The function is yielding the following error.
Error: Unexpected MATLAB expression.
So, I tried out the following input:(With quotes for equations)
syms x(t) r(t) s(t) q(t) >> [x,r,s,q]=dsolve('40000*x-20000*s-20000*q+500*diff(x)-250*diff(s)-250*diff(q)+750*diff(diff(x))==0','90000*r+30000*s-30000q+1125*diff(r)+375*diff(s)-375*diff(q)+1000*diff(diff(r))==0','-20000*x+30000*r+220000*s-250*diff(x)+375*diff(r)+250*diff(s)+35*diff(diff(s))==2000000,-20000*x+30000*r+220000*q-250*diff(x)+375*diff(r)+250*diff(q)+35*diff(diff(q))==2000000',x(0)==0,r(0)==0,s(0)==0,q(0)==0);
Which resulted in the following error:
Error using sym>convertExpression (line 2246) Conversion to 'sym' returned the MuPAD error: Error: Unexpected 'identifier'. [line 1, col 112]
Error in sym>convertChar (line 2157) s = convertExpression(x);
Error in sym>convertCharWithOption (line 2140) s = convertChar(x);
Error in sym>tomupad (line 1871) S = convertCharWithOption(x,a);
Error in sym (line 104) S.s = tomupad(x,'');
Error in dsolve>mupadDsolve (line 324) sys = [sys_sym sym(sys_str)];*
Hope, You can help me out..
With Regards
Nishanth
I read in the examples for dsolve. It's necessary to use diff(r,2) instead of diff(diff(r)) (same for the other unknown functions).
By the way: You have 4 second order equations ; so you will need 8 boundary conditions instead of 4 to fix the solution.
Best wishes
Torsten.
As you suggested, I tried out diff(r,2) & also added the the needed boundary conditions.
syms x(t) r(t) s(t) q(t) [x,r,s,q]=dsolve('40000*x-20000*s-20000*q+500*diff(x)-250*diff(s)-250*diff(q)+750*diff(x,2)==0', '90000*r+30000*s-30000q+1125*diff(r)+375*diff(s)-375*diff(q)+1000*diff(r,2)==0', '-20000*x+30000*r+220000*s-250*diff(x)+375*diff(r)+250*diff(s)+35*diff(s,2)==2000000', '-20000*x+30000*r+220000*q-250*diff(x)+375*diff(r)+250*diff(q)+35*diff(q,2)==2000000', 'diff(x(0))==0','diff(r(0))==0','diff(s(0))==0','diff(q(0)==0)','x(0)==0','r(0)==0','s(0)==0','q(0)==0');
Still no output. It is yielding the same errors as earlier. Would like to hear from you, on this. Please, need the community's help to resolve this.
Why do you still use ' ' to frame your equations ? They are wrong.
Best wishes Torsten.
So, does this call to dsolve work ? If not, what is the error message ?
syms x(t) r(t) s(t) q(t)
[x,r,s,q]=dsolve(40000*x-20000*s-20000*q+500*diff(x)-250*diff(s)-250*diff(q)+750*diff(x,2)==0,90000*r+30000*s-30000q+1125*diff(r)+375*diff(s)-375*diff(q)+1000*diff(r,2)==0,-20000*x+30000*r+220000*s-250*diff(x)+375*diff(r)+250*diff(s)+35*diff(s,2)==2000000,-20000*x+30000*r+220000*q-250*diff(x)+375*diff(r)+250*diff(q)+35*diff(q,2)==2000000, Dx(0)==0,Dr(0)==0,Ds(0)==0,Dq(0)==0,x(0)==0,r(0)==0,s(0)==0,q(0)==0);
Best wishes
Torsten.
I used '' to frame my equations, because that is how the function defines me to do it.
And Mr.Torsten the one you suggested above, returns the following message
Error: Unexpected MATLAB expression.
Last attempt:
syms x(t) r(t) s(t) q(t)
Dx=diff(x);
Dr=diff(r);
Ds=diff(s);
Dq=diff(q);
D2x=diff(x,2);
D2r=diff(r,2);
D2s=diff(s,2);
D2q=diff(q,2);
[X,R,S,Q]=dsolve(40000*x-20000*s-20000*q+500*Dx-250*Ds-250*Dq+750*D2x==0,90000*r+30000*s-30000q+1125*Dr+375*Ds-375*Dq+1000*D2r==0,-20000*x+30000*r+220000*s-250*Dx+375*Dr+250*Ds+35*D2s==2000000,-20000*x+30000*r+220000*q-250*Dx+375*Dr+250*Dq+35*D2q==2000000,Dx(0)==0,Dr(0)==0,Ds(0)==0,Dq(0)==0,x(0)==0,r(0)==0,s(0)==0,q(0)==0);
Best wishes
Torsten.

Sign in to comment.

Products

Asked:

on 5 Feb 2015

Commented:

on 10 Feb 2015

Community Treasure Hunt

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

Start Hunting!