Optimal control using dsolve error
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am trying to simulate optimal control problem using the method/example provided in Link, but for a different system.. But I am getting following error.
Error using mupadengine/feval (line 187)
Invalid number of arguments.
Error in dsolve>mupadDsolve (line 340)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 194)
sol = mupadDsolve(args, options);
Error in PMP_18012019 (line 35)
sol_h = dsolve(eq1,eq2);
clear;
%Initializations and values of constant variables
C = 28;
Rs = 0.01;
Rp = 10e3;
Vsmax = 305;
Preq = 50e3;
k = 1;
Vb = 360;
Rb = 0.3;
p1 = 0.4;
% State equations
syms x1 Pb p1 z; %Pb control variable & x1 = SOC_s is state variable
Dx1 = -1/C*((1/(2*Rs)+1/Rp)*x1-1/(2*Rs)*sqrt(x1^2-4*Rs/Vsmax^2*(Preq-Pb)));
% Cost function inside integral
syms g;
g = k*((Vb - sqrt(Vb^2 - 4*Rb*Pb))/(2*Rb))^2;
% Hamiltonian
syms p1 H;
H = g + p1*Dx1;
% Costate equations
% Dx1 = diff(H,p1);
Dp1 = -diff(H,x1);
% Solve for control Pb
dPb = diff(H,Pb);
sol_Pb = solve(dPb,Pb);
% Substitute Pb to state equations
Dx1 = subs(Dx1,Pb,sol_Pb);
% Convert symbolic objects to strings for using 'dsolve'
eq1 = strcat('Dx1=',char(Dx1));
eq2 = strcat('Dp1=',char(Dp1));
% consA1 = 'Dx1(0)=0';
% consA2 = 'Dp(0) = 0 ';
sol_h = dsolve(eq1,eq2);
% Use boundary conditions to determine the coefficients
% Case a: (a)Dx1(0)=90 Dx1(tf)=50
conA1 = 'x1(0) = 0';
conA2 = 'x1(10) = 1';
sol_a = dsolve(eq1,eq2,conA1,conA2);
% plot solutions
figure(1)
ezplot(sol_a.x1,[0 1]); hold on;
ezplot(sol_a.p1,[0 1]); % plot the control u=-p1
axis([0 20 0 1]);
xlabel('time');
ylabel('states');
title('Solution of PMP')
댓글 수: 4
답변 (1개)
Walter Roberson
2019년 2월 7일
r2018a does not permit dsolve of systems expressed as character vectors and so is thinking those are option names. You need to rewrite into symbolic expressions and
syms x1(t)
dx1 = diff(x1)
dsolve(dx1 == DX1)
or as appropriate .
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Special Values에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!