File Exchange

image thumbnail

circular diff

version 1.1.0.0 (1.49 KB) by Petorr
diff with wrap-around differences, same sized output matrix

2 Downloads

Updated 19 Dec 2013

View License

difc is a wrapper for matlab's diff() and takes the same arguments.

The returned matrix size is the same as the input matrix size, like matlab's gradient().

Higher N works using recursion.
Zero N returns the input matrix.

Cite As

Petorr (2020). circular diff (https://www.mathworks.com/matlabcentral/fileexchange/44701-circular-diff), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Petorr

Version 1 -- To keep the memory footprint small (and the code very simple), sum() is used to calculate the wrapped values from the result of diff. This may cause slowness or numerical error in some cases.

Updates

1.1.0.0

Previous version had faulty automatic dimension assignment when the function is called with a single argument.

It has been updated to match diff() defaults for vector, matrix and N-dim arrays.

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

Inspired: center_finite_diff.m