simpsonc.m

来自「sareli<matlab科学计算>配套程序」· M 代码 · 共 15 行

M
15
字号
function [Isic]=simpsonc(a,b,M,f,varargin)%SIMPSONC Composite Simpson numerical integration.%   ISIC = SIMPSONC(A,B,M,FUN) computes an approximation of the integral %   of the function FUN via the Simpson method (with M equispaced intervals).%   FUN accepts real scalar input x and returns a real scalar%   value. FUN can also be an inline object.H=(b-a)/M;x=linspace(a,b,M+1);fpm=feval(f,x,varargin{:});fpm(2:end-1) = 2*fpm(2:end-1);Isic=H*sum(fpm)/6;x=linspace(a+H/2,b-H/2,M);fpm=feval(f,x,varargin{:});Isic = Isic+2*H*sum(fpm)/3; return

⌨️ 快捷键说明

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