trapz_dke_yp

PURPOSE ^

SYNOPSIS ^

function [sf] = trapzyp(f)

DESCRIPTION ^

    Numerical integration by the trapeze's method of a function y = f(x).
    Steps may be irregular. 

    Input:

        - f: [x,f1,f2,...,fn], x is the abciss vector, fi are n functions [m,n+1]

    Output:

        - sf: [sf1,sf2,...,sfn], sum of fi's [m,n] 


by Y.PEYSSON CEA-DRFC 11/10/1991 <peysson@drfc.cad.cea.fr>
revised for MatLab 4.1 (31/08/1994) 
revised for MatLab 5.2 (31/08/2000)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [sf] = trapzyp(f)
0002 %
0003 %    Numerical integration by the trapeze's method of a function y = f(x).
0004 %    Steps may be irregular.
0005 %
0006 %    Input:
0007 %
0008 %        - f: [x,f1,f2,...,fn], x is the abciss vector, fi are n functions [m,n+1]
0009 %
0010 %    Output:
0011 %
0012 %        - sf: [sf1,sf2,...,sfn], sum of fi's [m,n]
0013 %
0014 %
0015 %by Y.PEYSSON CEA-DRFC 11/10/1991 <peysson@drfc.cad.cea.fr>
0016 %revised for MatLab 4.1 (31/08/1994)
0017 %revised for MatLab 5.2 (31/08/2000)
0018 %
0019 if nargin < 1,
0020     infoyp(2,'Wrong number of input arguments for trapz_dke_yp');
0021     return;
0022 end
0023 %
0024 [m,n] = size(f);
0025 %
0026 if m > 2,
0027     delta = f(2:1:m,1)-f(1:1:m-1,1);
0028     ff = (f(2:1:m,2:1:n) + f(1:1:m-1,2:1:n))/2;
0029     sf = sum((delta*ones(1,n-1)).*ff);
0030 elseif m == 2,
0031     sf = (f(1,2:1:n) + f(2,2:1:n))/2;
0032 elseif m == 1,
0033     sf = f(1,2:1:n);
0034 elseif m == 0,
0035     error('Empty matrix in trapz_dke_yp');
0036 end
0037

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.