Modified trapezoidal integration over specific limits of integration.

版本 1.0.0.0 (1.7 KB) 作者: Damon Bradley
This function is similar to trapz, except it specifies upper and lower integration limits a and b.
680.0 次下载
更新时间 2012/3/20

查看许可证

% function y = trapint(f,x,a,b)
% Author: Damon Bradley
% Purpose: Modified trapezoidal integration over specific limits of integration.
% Last revised: Tuesday, March 20, 2012
%
% Inputs:
% ----------------------------------------------
% x - Domain of function f
% f - A fuction defined by a vector of points
% a - Lower limit of integration
% b - Upper limit of integration
%
% NOTE: If a and b are not specified, this function is reduced to the
% normal trapz function
%
% Outputs:
% ----------------------------------------------
% y - Integration result
%
% Prerequisites:
% None
%
% Usage Example
% clear
% clc
% close all
% N=1000000; mu=5; sig=1; % Define parameters for an N-sample Gaussian random vector
% [counts bins] = hist(mu+sig*randn(N,1),sqrt(N)); % Compute histogram.
% p = counts/((bins(2)-bins(1))*N); % Compute corresponding PDF
% stairs(bins,p)
% y=trapint(bins,p,mu,inf) % Integrate from the mean to infinity. Should get 0.5 in theory.
% y =
%
% 0.5019

引用格式

Damon Bradley (2024). Modified trapezoidal integration over specific limits of integration. (https://www.mathworks.com/matlabcentral/fileexchange/35738-modified-trapezoidal-integration-over-specific-limits-of-integration), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2009a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0