Error using mupadengine/feval (line 187) Invalid equations.

12 次查看(过去 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!

采纳的回答

Jyothis Gireesh
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 CenterFile Exchange 中查找有关 Applications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by