フィルターのクリア

Solve the Lotka-Volterra differential equation system with the Hamiltonian function

1 回表示 (過去 30 日間)
Aron Horvath
Aron Horvath 2020 年 11 月 23 日
編集済み: Aron Horvath 2020 年 11 月 23 日
I have the following code where I would like to solve the system with dsolve but somehow I get the following error:
No differential equations found. Specify differential equations by using symbolic functions.
I started to work on optimal control with binary control functions, but I have already stucked in here.
Here's my code:
c0 = 0.5;
c1 = 0.7;
% state equations
syms x0 x1 lambda0 lambda1 w
dx0 = x0-x0*x1-c0*x0*w;
dx1 = -x1+x0*x1-c1*x1*w;
%objective function
syms g;
g = (x0-1)^2+(x1-1)^2;
%hamiltonian function;
syms lambda0 lambda1 H;
H = -g+lambda0*dx0+lambda1*dx1;
%"costate equations"
dlambda0 = -diff(H,x0);
dlambda1 = -diff(H,x1);
%solve for control w
dw = diff(H,w);
sol_w = solve(dw,w);
% Substitute w to state equations
dx1 = subs(dx1, w, sol_w);
% convert symbolic objects to strings for using ’dsolve’
eq1 = strcat('dx0=',char(dx0));
eq2 = strcat('dx1=',char(dx1));
eq3 = strcat('dlambda0=',char(dlambda0));
eq4 = strcat('dlambda1=',char(dlambda1));
% HERE IS THE PROBLEM
sol_h = dsolve(eq1,eq2,eq3,eq4)
Thank you for your help !

回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by