1 Star 0 Fork 1

NUDTexplorer/OptimTraj

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
simpsonQuadrature.m 825 Bytes
一键复制 编辑 原始数据 按行查看 历史
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nudtexplorer/OptimTraj.git
git@gitee.com:nudtexplorer/OptimTraj.git
nudtexplorer
OptimTraj
OptimTraj
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385