Unable to find explicit solution
Show older comments
Can someone please help me to figure out what is wrong with this code. When I run it I got the following error
Warning: Unable to find explicit solution. For options, see help.
Error using mupadengine/feval_internal
Invalid equation or initial condition.
Error in dsolve>mupadDsolve (line 334)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 203)
sol = mupadDsolve(args, options);
sol_h = dsolve(eq1,eq2,eq3,eq4,eq5,eq6);
% state equation
syms x1(t) x2(t) x3(t) w1(t) w3(t) p1(t) p2(t) p3(t)
DX1 = -w3*x2;
DX2 = w3*x1 - w1*x3;
DX3 = w1*x2;
% Cost function inside the integral
syms g;
g = pi/sqrt(2);
% Hamiltonian
syms x1(t) x2(t) x3(t) w1(t) w3(t) p1(t) p2(t) p3(t) H
H = g -(p1*w3*x2) + p2(w3*x1-w1*x3)+(p3*w1*x2);
% costate equations
Dp1 = -diff(H,x1);
Dp2 = -diff(H,x2);
Dp3 = -diff(H,x3);
% solve for control w
dw1 = diff(H,w1);
sol_w1 = solve(dw1,w1);
dw3 = diff(H,w3);
sol_w3 = solve(dw3,w3);
% substitute w to state eq
DX1 = subs(DX1, {w1 w3}, {sol_w1 sol_w3});
DX2 = subs(DX2, {w1 w3}, {sol_w1 sol_w3});
DX3 = subs(DX3, {w1 w3}, {sol_w1 sol_w3});
% convert symbolic objects to string for using 'dsolve'
eq1 = strcat('DX1=',char(DX1));
eq2 = strcat('DX2=',char(DX2));
eq3 = strcat('DX3=',char(DX3));
eq4 = strcat('Dp1=',char(Dp1));
eq5 = strcat('Dp2=',char(Dp2));
eq6 = strcat('Dp3=',char(Dp3));
sol_h = dsolve(eq1,eq2,eq3,eq4,eq5,eq6);
% Use Boundary condition
syms cond1 cond2 cond3 cond4 cond5 cond6
cond1 = 'x1(0) == 1';
cond2 = 'x2(0) == 0';
cond3 = 'x3(0) == 0';
cond4 = 'x1(2 == 0';
cond5 = 'x2(2) == 0';
cond6 = 'x3(2) == 1';
sol_H = dsolve(eq1,eq2,eq3,eq4,eq5,eq6,cond1,cond2,cond3,cond4,cond5,cond6);
Thank you for your help.
Accepted Answer
More Answers (0)
Categories
Find more on Formula Manipulation and Simplification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!