Error using mupadengine/feval (line 187) Invalid equations.
7 ビュー (過去 30 日間)
古いコメントを表示
I am trying to solve a differential equation, but getting the following error
Error using mupadengine/feval (line 187)
Invalid equations.
My code:
syms r(P);
eqn = diff(r,P,2) == (r^4 / b^2) - (1-k/r)*(r^4/a^2 + r^2);
Dr = diff(r,P);
cond = [ r(0) == 0.1, Dr(0) == 0.1];
rsol(P) = dsolve(eqn ,[0 10], cond);
All the variables used (a,k,b) are defined in the code before.
Will be grateful for any help!
0 件のコメント
採用された回答
Jyothis Gireesh
2019 年 12 月 31 日
I am assuming here that you want the solution to be evaluated over the range [0 10]. But according to MATLAB documentation, the "dsolve()" doesn’t provide the functionality to provide that as an input argument to the function.
I tried running the above code by initializing the values of "a", "b" and "k" with value 1 which didn't yield an explicit solution. In case such a situation arises, it may be better to use numerical integration techniques as ode45. The following code may be useful in case of numerical methods
clear;
syms r(p)
a=2;
b=1;
k=1;
eqn = diff(r,p,2) == r^4/b^2 - (1-k/r)*(r^4/a^2 + r^2);
Dr = diff(r,p);
V = odeToVectorField(eqn);
F = matlabFunction(V, 'vars', {'p','Y'});
rsol = ode45(F,[0 10], [0.1 0.1])
Hope this helps!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!