SIMPCX. Composite Simpson Quadrature Formula function [int]=simpc(xx,yy) Input: xx equispaced abscissas, size(xx) has to be odd yy ordinates Output: int computed integral Autori: pg
0001 function [int]=simpcx(xx,yy) 0002 % SIMPCX. Composite Simpson Quadrature Formula 0003 % function [int]=simpc(xx,yy) 0004 % 0005 % 0006 % Input: 0007 % xx equispaced abscissas, size(xx) has to be odd 0008 % yy ordinates 0009 % 0010 % Output: 0011 % int computed integral 0012 % 0013 % Autori: pg 0014 h=xx(3)-xx(1); 0015 n=length(yy); 0016 int=0; 0017 m=fix(n/2); 0018 for i=1:2:n-2 0019 int=int+yy(i)+yy(i+2)+4*yy(i+1); 0020 end 0021 int=int*h/6;