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

📄 cncqf.m

📁 小的源码Matlab编程
💻 M
字号:

function [s, w, x] = cNCqf(fun, a, b, n, varargin)

% Numerical approximation s of the definite integral of
% f(x). fun is a string containing the name of the integrand f(x). 
% Integration is over the interval [a, b]. 
% Method used:
% n-point closed Newton-Cotes quadrature formula.
% The weights and the nodes of the quadrature formula
% are stored in vectors w and x, respectively.

if n < 2
   error(' Number of nodes must be greater than 1')
end
x = (0:n-1)/(n-1);
f = 1./(1:n);
V = Vander(x);
V = rot90(V);
w = V\f';
w = (b-a)*w;
x = a + (b-a)*x;
x = x';
s = feval(fun,x,varargin{:});
s = w'*s;




⌨️ 快捷键说明

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