View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 5 ratings Rate this file 21 Downloads (last 30 days) File Size: 65.8 KB File ID: #29312 Version: 1.2
image thumbnail




08 Nov 2010 (Updated )

Second-order accurate numerical differentiation (N-dimensional)

| Watch this File

File Information

In its simplest usage DIFFXY uses a second-order accurate scheme to approximate the derivative of a vector y with respect to a vector x. It differs from existing functions in the following ways:

- returns dydx having the same size as y (unlike DIFF which reduces the dimension by 1)
- special treatment of end-points for higher accuracy
- specifically built to handle unequally spaced data

DIFFXY also has the following capabilities

- x and y can be N-dimensional arrays
- operate on chosen dimension of N-d arrays
- computes higher-order derivatives via iteration

See the Help section and demo file for examples and further information.
Please suggest any improvements/report any bugs either in the comments or via email.


Derivative inspired this file.

This file inspired D Gradient.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
20 Jun 2016 jongmin

Really good and straightforward, convenient to use.

07 May 2014 Maarten

Hi Darren,

Great script you have here. Do you have any ideas where i can find some more information about the differentiation algorithm you are using?


Comment only
07 May 2014 Maarten

20 Mar 2014 Philip Ohnewein

29 Jan 2014 Philip Ohnewein

Tested it for 1-dimensional data only: Easy to use, does exactly what it is expected to do. Thank you very much!

30 Jan 2013 Nek Valous

18 Nov 2010 Darren Rowland

@ Carlos,
Yes this will handle equally spaced data too. The formula I have used reduces to the central difference formula when the data are equally spaced, so the result is mostly the same as GRADIENT in that case.
The first example in the file demo_diffxy demonstrates the case of equally spaced points (follow the link next to 'Published MATLAB Files' above to view).

Comment only
16 Nov 2010 Carlos

Carlos (view profile)

I noticed that you specified that this file was made to handle unequally spaced data but, I was wondering if it can also handle equally spaced data? Thank you.

Comment only
08 Nov 2010 1.2

9 Nov 2010 - minor update to demo file to correct figure legend and screenshot

Contact us