Code covered by the BSD License  

Highlights from
Numerical Methods Using MATLAB, 3e

image thumbnail

Numerical Methods Using MATLAB, 3e

by

 

20 Aug 2002 (Updated )

Companion Software

quad=gauss(f,a,b,A,W)
function quad=gauss(f,a,b,A,W)

%Input   - f is the integrand input as a string 'f'
%        - a and b upper and lower limits of integration
%        - A is the 1 x N vector of abscissas from Table 7.9
%        - W is the 1 x N vector of weights from Table 7.9
%Output  - quad is the quadrature value

% NUMERICAL METHODS: MATLAB Programs
%(c) 1999 by John H. Mathews and Kurtis D. Fink
%To accompany the textbook:
%NUMERICAL METHODS Using MATLAB,
%by John H. Mathews and Kurtis D. Fink
%ISBN 0-13-270042-5, (c) 1999
%PRENTICE HALL, INC.
%Upper Saddle River, NJ 07458

N=length(A);
T=zeros(1,N);
T=((a+b)/2)+((b-a)/2)*A;
quad=((b-a)/2)*sum(W.*feval(f,T));

Contact us