Warning: Explicit solution could not be found./ empty sym

1 回表示 (過去 30 日間)
Kees
Kees 2024 年 10 月 8 日
移動済み: Torsten 2024 年 10 月 9 日
hi i get an error on the last line with this program:'Warning: Explicit solution could not be found.',' empty sym', i already tried to adjust the constraints but to na avail...there is a warning included as well in this exercise :Warning: Solutions are valid under the following conditions: e + m ~= 0. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.... i did not succeed in including this...this is the code:
clear all
syms e P S A t m V0 t0 V(t) real
IC = V(t0)==10
diffeq = diff(V,t) == P + e*V(t) - m*(S-(V(t)))
Vsol = simplify(dsolve([diffeq,IC],symvar(V(t))))
V0val = solve(subs(Vsol,t,t0)==0,V0,e + m == 0)

回答 (1 件)

John D'Errico
John D'Errico 2024 年 10 月 8 日
編集済み: John D'Errico 2024 年 10 月 8 日
Does an analytical solution exist for EVERY equation you can write down? (No.) Even if such a solution does exist, is it certain that a solver tool will always find one? (Again, no.) Is there a reason why what you wrote failed? Well, yes.
syms e P S A t m V0 t0 real
syms V(t)
I said this the last itme you asked this question. You cannot tell MATLAB that V(t), as an unknown function, is real.
IC = V(t0)==10;
diffeq = diff(V,t) == P + e*V(t) - m*(S-(V(t)));
Vsol = simplify(dsolve([diffeq,IC],symvar(V(t))));
Vsol =
(S*m - P + exp((e + m)*(t - t0))*(P + 10*e + 10*m - S*m))/(e + m)
(Answers is currently broken, so I have displayed the command line results from my own off-line version.)
So a solution does exist for the differential equation. It is in the case of solve where it fails.
Now, what does the constraint mean, that e+m must not be zero? THINK. Does that solution for Vsol have a divide by the expression e+m? What happens when e+m == 0? The result is a divide by 0, an operation with no well defined answer, especially when the numerator may also be zero too.
So telling solve to solve for the problem where e+m==0 is just completely meaningless. Again, look at what you are doing.
For e+m NOT equal to zero, when t == t0, what happens? Paper and pencil would suffice, but this is a MATLAB forum, so...
V0 = subs(Vsol,t,t0)
V0 =
(10*e + 10*m)/(e + m)
simplify(V0)
ans =
10
Therefore, V(t0) == V0 = 10.
And again, this is valid ONLY when e+m~=0. When the sum is zero, then potentially, no solution exists, since we would have 0/0. However, you could talk about the limit. And that should exist in this specific case. I'll take the limit as e approaches -m.
limit(v0,e,-m)
ans =
10
  2 件のコメント
Kees
Kees 2024 年 10 月 9 日
移動済み: Torsten 2024 年 10 月 9 日
first of all i did not read your answer last time, i used the answer of rahul...which worked fine at the time, second i got the same error when i leave e+m=0 out ....imust say my math is a bit rusty but according to mij book the answer: V0val = solve(subs(Vsol,t,t0)==0,V0)
should work...as i using an older version my thought was tis is a version problem
Kees
Kees 2024 年 10 月 9 日
移動済み: Torsten 2024 年 10 月 9 日
but i see what you mean with your remark about e+m you are right ....and also i removed the real assignment.....

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by