File Exchange

image thumbnail

diffCenter

version 2.0.0.0 (1.45 KB) by Matthew Kelly
Computes the second-order finite difference approximation.

235 Downloads

Updated 30 Dec 2015

View License

% dx = diffCenter(x,dt)
%
% Computes the second-order finite difference approximation of x with
% respect to t. A one-sided second order difference is used at the end
% points, so size(dx) == size(x).
%
% INPUTS:
% x = [m, n] = matrix of function values over a uniform time grid n
% dt = sampling period of x (default = 1)
%
% OUTPUTS:
% d = dx/dt = first derivative of x wrt t
%
% NOTES:
% This command is very similar to Matlab's gradient command. The
% difference between the two is how they handle the boundaries.
% DiffCenter (this function) uses a second-order finite difference,
% while gradient (by Matlab) uses a first-order finite difference.
% The functions are identical for interior points.
%
% See also: cumInt, diff, gradient
%

Cite As

Matthew Kelly (2021). diffCenter (https://www.mathworks.com/matlabcentral/fileexchange/54459-diffcenter), MATLAB Central File Exchange. Retrieved .

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

Inspired: diffCenterVar

Community Treasure Hunt

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

Start Hunting!