function [ ] = prob_1_15_ode45 % % Written by: % -- % John L. Weatherwax 2005-05-07 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % Parameters: global a c; a=2; c=1; % Initial conditions: y0 = [ 1 3 ]; % Final time: tmax = 10.0; % A sample of step sizes: hArray = 10.^[-1:-1:-4]; %hArray = 10.^[-1]; for hi=hArray, [ t, y ] = ode45(@prob_1_15_odefun,[0:hi:tmax],y0); figure; plot( y(:,1), y(:,2), '-o' ); title( [ 'hi = ', num2str(hi) ] ); plotBigG( t, y(:,1), y(:,2), hi ); end return; %------------------------------------------------------------------------ %------------------------------------------------------------------------ function [ yprime ] = prob_1_15_odefun( t, y ) global a c; yprime = [ a*y(1)*(1-y(2)); -c*y(2)*(1-y(1)) ]; return; %------------------------------------------------------------------------ %------------------------------------------------------------------------ function [] = plotBigG( t, x, y, hi ) global a c; G = x.^(-c) .* y.^(-a) .* exp( c*x + a*y ); figure; plot( t, G, '-o' ); xlabel( 'time (s)' ); ylabel( 'G (unitless)' ); title( [ 'hi = ', num2str(hi) ] ); return;