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

조회 수: 3 (최근 30일)
Lada Nuzhna
Lada Nuzhna 2019년 12월 28일
댓글: Lada Nuzhna 2020년 1월 1일
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에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by