5.0

5.0 | 2 ratings Rate this file 4 Downloads (last 30 days) File Size: 2.79 KB File ID: #23204

2D Simpson's Integrator

by Whayne Padden

 

05 Mar 2009

Fully vectorised 2D integrator based on the Simpson's method

| Watch this File

File Information
Description

Fast, fully vectorised version of the Simpson's method for 2D domains. This code avoids the use of any for loops etc. For a given level of accuracy it can be an order of magnitude or more faster than dblquad.

Examples are provided within the code.

Useage:

ans = simp2D('func',xs,xe,ys,ye,NX,NY)

Input parameters:

func - 2D function that accepts vector inputs (otherwise
           incorrect results can occur)
xs, xe - x-limits of integration
ys, ye - y-limits of integration
NX - number of integration intervals in the x-direction (should be even)
NY - number of integration intervals in the y-direction (should be even)

Acknowledgements

2 D Simpson's Integrator and 3 D Simpson's Integrator inspired this file.

This file inspired 2 D Simpson's Integrator, 3 D Simpson's Integrator, and Cms Spread Caps Stochastic Local Volatility Libor Market Model.

MATLAB release MATLAB 7.3 (R2006b)
Other requirements On a system with 1GB memory you'll be restricted to less than 4096 intervals in each direction.
Tags for This File  
Everyone's Tags
2d(2), integration(2), mathematics, simpsons method(2)
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
18 Apr 2012 abc

Thanks a lot!

09 Dec 2010 ehsan

I want to get 2Dimensional Integration from Images,but i couldn't find any code.
please would you help me.

28 Sep 2010 erick

very good work. but I have a question.
In your code, you gave out the odd series and even series as follows.
ixo = 2:2:NX;
ixe = 3:2:NX-1;
iyo = 2:2:NY;
iye = 3:2:NY-1;

if you choose 'o' as 'odd' , 'e' as 'even', the series 2:2:NX are even. so I think 'ixo = 2:2:NX' should be replaced by 'ixe = 2:2:NX'.

Is there a literal mistake, maybe the below code is right.
ixe = 2:2:NX;
ixo = 3:2:NX-1;
iye = 2:2:NY;
iyo = 3:2:NY-1;

Contact us