% % 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. % %----- close all; clc; clear; % set the constants of this problem: t_0 = 0.; t_f = 10.; gamma_0 = pi/2.; gamma_d = pi/3.; v_0 = 100.; d_gamma = 1; % test the two values of d_gamma %d_gamma = 10; % test the two values of d_gamma % find the optimal value for [alpha_0,alpha_1]: % alphas = fminsearch( @(x) sect_3_prob_2_part_d_J_min_fn(x(1), x(2), t_0, t_f, v_0, gamma_0, gamma_d, d_gamma), [ 0., 0. ] ); alphas % evaluate J at this value of alpha sect_3_prob_2_part_d_J_min_fn(alphas(1), alphas(2), t_0, t_f, v_0, gamma_0, gamma_d, d_gamma) % look at how well the various end conditions match sol = ode45( @(t,x) sect_3_prob_2_part_d_J_ode_fn(t,x, alphas(1),alphas(2)), [t_0,t_f], [v_0;gamma_0] ); gamma_d - sol.y(2,end)