%% Annotated Matlab transcript -- 4/12 %% CS 323 - Doug DeCarlo % Matlab integration example using code from book [i,d,r] = simpson(0,pi/2,2,0); i d r es = 1 - i; % ratio of simpson error is 16 es(1:end-1) ./ es(2:end) trapezoidal(0,pi/2,2,0) et = 1 - trapezoidal(0,pi/2,2,0) plot(1:length(et),et,'.-') semilogy(1:length(et),abs(et),'.-') % ratio of trapezoid error is 4 et(1:end-1) ./ et(2:end) % plotting both errors... plot(1:length(et),et,'.-',1:length(es),es,'.-r'); semilogy(1:length(et),abs(et),'.-',1:length(es),abs(es),'.-r');