Code covered by the BSD License  

Highlights from
quad3

image thumbnail

quad3

by

 

Evaluates cubic polynomial numerical integration

quad3(X,Y)
function Z = quad3(X,Y)
% quad3 - evaluates cubic polynomial numerical integration
% Z = quad3(X,Y) computes an approximation of the integral of Y with 
%    respect to X using cubic polynomial method. Requires 7N mult + 3N add.
%
% Syntax:  Z = quad3(X,Y)
%
% Inputs:
%   X - function x values : y=f(x)
%   Y - function y values
%
% Outputs:
%   Z - intagral approximation values
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also: trapz, quad;

% Reference: Warren E. Ferguson Jr., Ian Gladwell & James G. Nagy
% Introduction to Scientific Computing unsing Matlab p. 155, 2004.
% Author: Marco Borges, Ph.D. Student, Computer/Biomedical Engineer
% UFMG, PPGEE, Neurodinamica Lab, Brazil
% email address: marcoafborges@gmail.com
% Website: http://www.cpdee.ufmg.br/
% June 2013; Version: v1; Last revision: 2013-06-30
% Changelog:
% 
%------------------------------- BEGIN CODE -------------------------------
S = spline(X,Y);
[~, a, N, ~] = unmkpp(S);
Z = 0;
h = diff(X);
parfor ii = 1:N
    %h = x(ii+1) - x(ii);
    Z = Z + h(ii)*(((a(ii,1)*h(ii)/4 + a(ii,2)/3)*h(ii) + ...
        a(ii,3)/2)*h(ii) + a(ii,4));
end
end
%-------------------------------- END CODE --------------------------------

Contact us