% Test of integration using table data % This case will use linear interpolation to grow the % number of points in the table. clear close all load intdata2.dat x = intdata2(:,1); y = intdata2(:,2); exact = 1.1064840; % Grow the table to 101 points [xo,yo] = growlin(x,y,100); figure(1) hold on plot(x,y,'b*') plot(xo,yo,'ro') hold off xlabel('x') ylabel('y') title('Original and interpolated points') % Get h and use trapezoidal and Simpson's rules. Table now has % an odd number of values, so can use Simpson's rule here. h = xo(2) - xo(1); % Trap rule t = trap_fun(h,y); rt = (t-exact)/exact % Simpsons rule s = simp_fun(h,y); rs = (s-exact)/exact