function [J] = sect_5_prob_5_J_min_fn(lambda_0, t_0, t_f, x0,T,xair,xd,k1,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 forward in time from t=0 to t=t_f: % sol = ode23s( @(t,x) sect_5_prob_5_ode_fn(t,x, T,xair,xd,k1,c1,c2), [t_0,t_f], [x0;lambda_0] ); x_t = sol.y(1,:); % extract x(t) lambda_t = sol.y(2,:); % extrat lambda(t) % Second evaluate the expression for J (make sure that lambda(t_f) matches the known values): % J = 0.5 * ( lambda_t(end) - 2*c1*(x_t(end)-xd) )^2;