function [J] = sect_5_prob_6_J_min_fn(lambda_0, t_0, t_f, x10,x20,T1,T2,xair,xd,k1,k2,c1,c2) % % Written by: % -- % John L. Weatherwax 2006-08-28 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % First integate the given differential equations from t=0 to t=t_f: % sol = ode23s( @(t,x) sect_5_prob_6_ode_fn(t,x, T1,T2,xair,xd,k1,k2,c1,c2), [t_0,t_f], [x10;x20;lambda_0(1);lambda_0(2)] ); x1_t = sol.y(1,:); % extract x_1(t) x2_t = sol.y(2,:); % extract x_2(t) lambda1_t = sol.y(3,:); % extract lambda_1(t) lambda2_t = sol.y(4,:); % extract lambda_2(t) % Second evaluate the expression for J (the final conditions on lambda1_t and lambda2_t should be zero): % J = 0.5 * ( ( lambda1_t(end) - 2*c1*(x1_t(end)-xd) )^2 + ( lambda2_t(end) - 2*c1*(x2_t(end)-xd) )^2 );