Code covered by the BSD License  

Highlights from
DIFFERENT

5.0

5.0 | 1 rating Rate this file 11 Downloads (last 30 days) File Size: 2.19 KB File ID: #31891
image thumbnail

DIFFERENT

by Jonas Lundgren

 

21 Jun 2011 (Updated 21 Nov 2011)

An alternative to GRADIENT for non-uniform grids.

| Watch this File

File Information
Description

GRADIENT approximates derivatives using centered difference quotients.
This is not very accurate for non-uniform grids, where differences
are not properly centered.

DIFFERENT uses the scheme: Forward + Backward - Centered difference quotients.
This is more accurate for non-uniform grids. For uniform grids the schemes are
equivalent. Interval endpoints are always treated differently.

DIFFERENT is at least a factor 2 faster than GRADIENT.

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
22 Jun 2011 Jan Simon

H1 line, detailed help text, examples, "See also" line, name of the author. The function accepts arrays and the dimension to operate on can be specified. The inputs are checked. The calculations are correct, vectorized and fast.
This submission is useful and usable and earns 5 stars.

For large arrays the creation of temporary arrays consumes much time. I've published a C-Mex function for the 2nd order gradient calculation without the need of temporary arrays, which is 12 times faster: http://www.mathworks.com/matlabcentral/fileexchange/29887-dgradient
And see Robert Canfield's evergreen central_difference: http://www.mathworks.com/matlabcentral/fileexchange/12

01 Jul 2011 Jonas Lundgren

Thank you Jan for your comments. A faster version will soon be available.

Please login to add a comment or rating.
Updates
28 Jun 2011

Screenshot added

01 Jul 2011

Major speed up

21 Nov 2011

New contact info

Tag Activity for this File
Tag Applied By Date/Time
approximation Jonas Lundgren 21 Jun 2011 10:33:25
derivative Jonas Lundgren 21 Jun 2011 10:33:25
differentiation Jonas Lundgren 21 Jun 2011 10:33:25
nonuniform Jonas Lundgren 21 Jun 2011 10:33:25
gradient Jonas Lundgren 21 Jun 2011 10:33:25
gradient Ashutosh Tewari 16 Nov 2011 15:22:04

Contact us at files@mathworks.com