% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % EPage 103 % close all; clc; clear all; addpath('../../BookCode'); y_truth = @(x) ( 50 * exp( - 5*x ) ); fprime = @(t,x) ( -5*x ); y0 = 50; hs = [ 0.1, 0.2, 0.25, 0.4 ]; colors = [ 'r', 'b', 'g', 'c' ]; phs = []; for hi=1:length(hs) [tvals,yvals] = abm( fprime, [0,6], y0, hs(hi) ); %relative_error = ( yvals - y_truth(tvals) ) ./ y_truth(tvals) ; %plot( tvals, relative_error, ['-',colors(hi)] ); ph = plot( tvals, yvals, ['-',colors(hi)] ); phs = [hs, ph]; hold('on'); end grid('on'); legend( 'h 0.1', 'h 0.2', 'h 0.25', 'h 0.4', 'location', 'best' ); %saveas( gcf, '../../WriteUp/Graphics/Chapter5/c_5_p_9_plot.eps', 'epsc' );