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);
回答(1 个)
Torsten
2015-2-5
0 个投票
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 个评论
Torsten
2015-2-6
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
Nishanth
2015-2-6
Torsten
2015-2-6
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.
Nishanth
2015-2-7
Torsten
2015-2-9
Why do you still use ' ' to frame your equations ? They are wrong.
Best wishes Torsten.
Torsten
2015-2-9
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.
Nishanth
2015-2-9
Torsten
2015-2-10
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Special Values 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!