⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trapzdat.m

📁 D:matlab mmintegrate.rar数值积分
💻 M
字号:
function I = trapzDat(x,f)
% trapzDat  Composite trapezoid rule for arbitrarily spaced discrete data
%
% Synopsis:  I = trapzDat(x,f)
%
% Input:     x = vector of independent variable data.  Assumed
%                to be unequally spaced
%            f = vector discrete function values to be integrated.  
%
% Output:    I = integral of f with respect to x

n = length(f);
if length(x)~=n,  error('Dimensions of x and f are incompatible');  end

dx   = diff(x);                  %  vector of x(i+1)-x(i) values
avef = f(1:n-1) + 0.5*diff(f);   %  vector of average f values
I = sum(avef.*dx);               %  avef(1)*dx(1) + avef(2)*dx(2) + ...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -