Optimal control using dsolve error

5 vues (au cours des 30 derniers jours)
Praveen Kumar
Praveen Kumar le 7 Fév 2019
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 commentaires
Stephan
Stephan le 7 Fév 2019
Modifié(e) : Stephan le 7 Fév 2019
sol_h = dsolve([eq1,eq2]);
...
sol_a = dsolve([eq1,eq2],[conA1,conA2]);
Praveen Kumar
Praveen Kumar le 7 Fév 2019
Made the above changes. Following error is displayed:
Error using symengine
Unexpected 'identifier'.
Error in mupadengine/evalin (line 132)
res = mupadmex(statement,output_type{:});
Error in dsolve>mupadDsolve (line 339)
sys = [sys_sym reshape(evalin(symengine, sys_str), 1, [])];
Error in dsolve (line 194)
sol = mupadDsolve(args, options);
Error in PMP_18012019 (line 37)
sol_h = dsolve([eq1,eq2]);

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 7 Fév 2019
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 .

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by