% % 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 136 addpath('../../BookCode'); close all; clc; clear xs = 0:0.25:3; ys = [ 6.3806, 7.1338, 9.1662, 11.5545, 15.6414, 22.7371, 32.0696, 47.0756, 73.1596, 111.4684, 175.9895, 278.5550, 446.4441 ]; plot( xs, ys, '.k', 'MarkerSize', 18 ); hold('on'); grid('on'); % Fit the exponential model using fgenfit: % c = fgenfit( 'c_7_p_6_fn_i', xs, ys ); ys_fn_i = c(1) + c(2) * exp( xs ) + c(3) * exp( 2 * xs ); plot( xs, ys_fn_i, '-k' ); % Fit the reciprical model using fgenfit: % c = fgenfit( 'c_7_p_6_fn_ii', xs, ys ); ys_fn_ii = c(1) + c(2)./(1+xs) + c(3)./((1+xs).^2); plot( xs, ys_fn_ii, '-r' ); % Fit a third degree polynomial to this data: % poly_coefs = polyfit( xs, ys, 3 ); ys_poly = polyval( poly_coefs, xs ); plot( xs, ys_poly, '-b' ); legend( 'data', 'exponential model', 'reciprical model', 'cubic', 'location', 'best' ); %saveas( gcf, '../../WriteUp/Graphics/Chapter7/c_7_p_6_plot.eps', 'epsc' );