fsum.m

来自「这是《Numerical Methods with MATLAB: Imple」· M 代码 · 共 15 行

M
15
字号
function s = fsum(fun,a,b,n)
% fsum  Computes sum of f(x) values at n points in  a <= x <= b
%
% Synopsis:   s = fsum(fun,a,b,n)
%
% Input:  fun = (string) name of the function, f(x), to be evaluated
%         a,b = endpoints of the interval
%         n   = number of points in the interval
%
% Output:  s = sum of f(x) at n discrete points in the interval

x = linspace(a,b,n);     %  create points in the interval
y = feval(fun,x);        %  evaluate function at sample points
s = sum(y);              %  compute the sum

⌨️ 快捷键说明

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