## Simpson's Rule Integration

버전 1.6.0.0 (1.71 KB) 작성자:
Computes an integral "I" via Simpson's rule in the interval [a,b] with n+1 equally spaced points

다운로드 수: 15.5K

업데이트 날짜: 2011/4/29

라이선스 보기

This function computes the integral "I" via Simpson's rule in the interval [a,b] with n+1 equally spaced points

Syntax: I = simpsons(f,a,b,n)

Where,
f= can either be an anonymous function (e.g. f=@(x) sin(x)) or a vector containing equally spaced values of the function to be integrated
a= Initial point of interval
b= Last point of interval
n= # of sub-intervals (panels), must be integer

Written by Juan Camilo Medina - The University of Notre Dame

Example 1:

Suppose you want to integrate a function f(x) in the interval [-1,1].
You also want 3 integration points (2 panels) evenly distributed through the
domain (you can select more point for better accuracy).
Thus:
f=@(x) ((x-1).*x./2).*((x-1).*x./2);
I=simpsons(f,-1,1,2)

Example 2:

Suppose you want to integrate a function f(x) in the interval [-1,1].
You know some values of the function f(x) between the given interval,
those are fi= {1,0.518,0.230,0.078,0.014,0,0.006,0.014,0.014,0.006,0}
Thus:
fi= [1 0.518 0.230 0.078 0.014 0 0.006 0.014 0.014 0.006 0];
I=simpsons(fi,-1,1,[])
note that there is no need to provide the number of intervals (panels) "n",
since they are implicitly specified by the number of elements in the vector fi

### 인용 양식

Juan Camilo Medina (2023). Simpson's Rule Integration (https://www.mathworks.com/matlabcentral/fileexchange/28726-simpson-s-rule-integration), MATLAB Central File Exchange. 검색됨 .

개발 환경: R2010a
모든 릴리스와 호환
##### 플랫폼 호환성
Windows macOS Linux
##### 카테고리
Help CenterMATLAB Answers에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.6.0.0

.

1.5.0.0

Added an extension to handle vectors as well and anonymous function.

1.4.0.0

1.3.0.0

.

1.2.0.0

.

1.1.0.0

n/a

1.0.0.0