필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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 CenterFile Exchange에서 Conversion 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