MATLAB Answers

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

22 views (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Jyothis Gireesh
Jyothis Gireesh on 31 Dec 2019
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!

More Answers (0)

Community Treasure Hunt

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

Start Hunting!