File Exchange

image thumbnail

Numerical Differentiation

version (249 KB) by Husam Aldahiyat
Performs single dimensional differentiation numerically.


Updated 03 Feb 2009

View Version History

View License

This is a GUI which performs numerical differentiation of a function over a number of equaly spaced points. Also with it is a code that grants the coefficients used for numerical differentiation.

The pictures and example should be more than enough for understanding how to use the file.


-1.5 2 -0.5 % Forward
-0.5 -0 0.5 % Central
0.5 -2 1.5 % Backward

% The result is a matrix consisting of coefficients that can be
% used to numerically differentiate, like this:


s = ( d(1,1)*f(x) + d(1,2)*f(x+h) + d(1,3)*f(x+2*h) )/h^Order
s =

s = ( d(2,1)*f(x-h) + d(2,2)*f(x) + d(2,3)*f(x+h) )/h^Order
s =

s = ( d(3,1)*f(x-2*h) + d(3,2)*f(x-h) + d(3,3)*f(x) )/h^Order
s =

% The true answer is s = -0.84147

The code uses the Symbolic Math Toolbox to obtain the true value (in order to calculate the error). If you don't have the Symbolic Math Toolbox then you won't enjoy this benefit (program still works though).

Cite As

Husam Aldahiyat (2021). Numerical Differentiation (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Mahdi S. Hosseini

A generalized framework called MaxPol has been recently published and made available here

MaxPol provides a framework to design variety of numerical differentiation kernels with properties like:
(1) Cutoff (lowpass) design with no side-lob artifacts (for noise-robust case)
(2) Arbitrary order of differentiation
(3) Arbitrary polynomial accuracy
(4) Derivative matrix design
(5) 2D Derivative Kernels with Steering moments
(6) Intuitive examples in Signal and Image processing

Zas Babyk

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Adaptive Robust Numerical Differentiation

Community Treasure Hunt

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

Start Hunting!