代码拉取完成,页面将自动刷新
function x = simpsonQuadrature(fun,tLow,tUpp,n)
% x = simpsonQuadrature(fun,tLow,tUpp,n)
%
% This function uses simpson quadrature over each of n uniform segments to
% approximate the integral of fun(t) on the interval tLow <= t <= tUpp
%
% INPUTS:
% fun = function handle
% f = fun(t)
% t = [1, nt] = time query points on [a,b]
% f = [nx, nt] = vector function at query points
% tLow = scalar lower bound on time
% tUpp = scalar upper bound on time
% n = number of segments to divide interval into
%
% OUTPUTS:
% x = [nx, 1] = integral along each dimension
%
nt = 2*n+1;
t = linspace(tLow,tUpp,nt);
f = fun(t);
nx = size(f,1);
dt = (tUpp-tLow)/n;
% Compute quadrature weights:
w = ones(nx,nt);
w(:,2:2:end) = 4;
w(:,3:2:(end-2)) = 2;
% Compute quadrature:
x = (dt/6)*sum(w.*f,2);
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。