% Test of integration using table data % This case will use a not-a-knot spline to grow the % number of points in the table, then send this table % to the trapezoidal and Simpson's rule function. clear close all load intdata2.dat x = intdata2(:,1); y = intdata2(:,2); exact = 1.1064840; % a = x(1) % b = x(end) S = spline(x,y); xo = linspace(x(1),x(end),101)'; yo = ppval(xo,S); h = xo(2)-xo(1); % Trapezoidal method % Trap rule t = trap_fun(h,yo); rt = (t-exact)/exact % Simpsons rule s = simp_fun(h,yo); rs = (s-exact)/exact % Spline sp = integral(@(x)ppval(x,S),x(1),x(end)); rsp = (sp-exact)/exact