HOW TO PLOT A GRAPH FOR THIS PROGRAM?
1 view (last 30 days)
Show older comments
HELLO DEAR ALL,
I REALLY NEED HELP IN COMPLETING THIS PROGRAM,AS I WISHED TO PLOT A GRAPH OF STATE-TIME,WITH VARIABLES x1,x2,and u presented.
THANK YOU VERY MUCH IN ADVANCE FOR SUGGESTIONS,COMMENTS,ADVICES...
HER IS THE PROGRAM THAT NEEDS TO BE FINISHED BY PLOT:
%State equations
syms x1 x2 p1 p2 u;
Dx1=-x2+u;
Dx2=x2;
%Cost functiuon inside the integral
syms g;
g=u^2;
%Hamiltonian
syms p1 p2 H;
H=g+p1*Dx1+p2*Dx2;
%Costate equations
Dp1=-diff(H,x1);
Dp2=-diff(H,x2);
%Solve for control u
du=diff(H,u);
sol_u=solve(du,´u´);
%Substitute u to state equations
Dx1=subs(Dx1,u,sol_u);
%Convert symbolic objects to strings for using dsolve
eq1=strcat(´Dx1=´,char(Dx1));
eq2=strcat(´Dx2=´,char(Dx2));
eq3=strcat(´Dp1=´,char(Dp1));
eq4=strcat(´Dp2=´,char(Dp2));
sol_h=dsolve(eq1,eq2,eq3,eq4);
% for boundary conditions : x1(0)=x2(0)=0;x1(2)=x2(2)=0.5;
conA1=´x1(0)=0´;
conA2=´x2(0)=0´;
conA3=´x1(2)=0.5;
conA4=´x2(2)=0.5;
sol_a=dsolve(eq1,eq2,eq3,eq4,conA1,conA2,conA3,conA4);
AND HOW TO PLOT A GRAPH FOR STATE-TIME?
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus 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!