Find the input profile that minimises the following.

Status
Not open for further replies.

immi

Newbie level 1
Joined
Dec 9, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291


proposed solution using matlab

syms u lam1 lam2 lam3 x1 x2 x3 real % define symbolic variables
x = [x1 x2 x3]';
lambda = [lam1 lam2 lam3]';

f = [(1-x(2)^2)*x(1)-x(2)+u;x(1);x(1)^2+x(2)^2+u^2];% State dynamics

phi = 0; L = x(3); % Terms in the objective function

H = L + lambda'*f;

lam_dot = -jacobian(H,x)';

lam_final = jacobian(phi,x)'

uopt = solve(diff(H,u),u);

x_dot = subs(f,u,uopt); %subs = subsitution of u with uopt in f[state equation]

zdot=@(t,z)[ ...
- z(2) - z(1)*(z(2)^2 - 1) - z(4)/(2*z(6));...
z(1); ...
z(1)^2 + z(2)^2 + z(4)^2/(4*z(6)^2); ...
z(4)*(z(2)^2 - 1) - z(5) - 2*z(6)*z(1); ...
z(4)*(2*z(1)*z(2) + 1) - 2*z(6)*z(2); ...
-1];

x0 = [0;1;0]; lam_final = [0;0;0];

BCres = @(a,b) [a(1:2:3)- x0;b(4:5:6)- (lam_final)]
solinit = bvpinit(linspace(0,5),[-5 1 0 0 1 5])
sol = bvp4c(zdot,BCres,solinit);

When the bvp4c is used i get error.
Any help regarding this problem. Thanks in advance
 

Attachments

  • Untitled.png
    48.1 KB · Views: 102

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…