File Exchange

image thumbnail


version (9.87 KB) by Geoff McDonald
Generates a 1D FIR filter to minimize the entropy of the filtered signal(s)


Updated 25 Oct 2015

View Version History

View License

This is the iterative 2D Minimum Entropy Deconvolution implemented according to an iterative method in the original paper:
R.A. Wiggins, Minimum Entropy Deconvolution, Geoexploration, vol. 16, Elsevier Scientific Publishing, Amsterdam, 1978. pp. 21–35.
Updated in 2015 to include the convolution adjustment fix. Proposed
in the second reference paper. This is important to fix MED from
deconvolving the trivial solution at the convolution discontinuity:
overlapMode = 'valid': Uses the convolution adjustment fix;
overlapMode = 'full': Uses the original convolution definition proposed by R.A. Wiggins. I don't recommend this.
Note to readers, you may want to refer to some of my other MED-based submissions:
This is a similar deconvolution problem posed by Carlos Cabrelli based on MED that
has a non-iterative solution directly for the optimal deconvolution filter. I recommend
checking this out if you are interested in MED, however often the non-optimal solution
reached by MED is a better expected result, since OMED is able to better achieve
the optimal solution of a single impulse.
This is the optimal solution to the periodic impulses and is recommended for rotating
machine faults instead of MED or OMED. Since it is non-iterative, it is able to
quickly generate spectrum's to diagnose machine health.

Algorithm Reference:
R.A. Wiggins, Minimum Entropy Deconvolution, Geoexploration, vol.
16, Elsevier Scientific Publishing, Amsterdam, 1978. pp. 21–35.

Convolution Adjustment:
G.L. McDonald, <others>, Multipoint Optimal Minimum Entropy Deconvolution and Convolution
Fix: Application to Vibration Fault Detection, unpublished

Signal to perform Minimum Entropy Deconvolution on. If a single
column/row of data is specified, a 1d filter is designed to
minimize the entropy of the resulting signals. If a 2d data
matrix is specified, a single 1d filter will be designed to
minimize the averaged entropy of each column of the filtered

This is the length of the finite inpulse filter filter to
design. Using a value of around 30 is appropriate depending on
the data. Investigate the performance difference using
different values.

termIter: (OPTIONAL)
This is the termination number of iterations. If the
the number of iterations exceeds this number, the MED process
will complete. Specify [] to use default value of 30.

termDelta: (OPTIONAL)
This is the termination condition. If the change in kurtosis
between iterations is below this threshold, the iterative
process will terminate. Specify [] to use the default value
of 0.01. You can specify a value of 0 to only terminate on
the termIter condition, ie. execute an exact number of

overlapMode: (OPTIONAL)
You should always use 'valid' for this parameter to include the
convolution fix that corrects MED erroneously deconvolving
spurious impulses. See algorithm reference section for
details on the convolution adjustment. You can use 'full' if you want
to reproduce the original MED results, but it is not recommended for
the above reason.

If this value is > 0, plots will be generated of the iterative
performance and of the resulting signal.

The input signal(s) x, filtered by the resulting MED filter.
This is obtained simply as: y_final = filter(f_final,1,x);

The final 1d MED filter in finite impulse response format.

Kurtosis according to MED iteration. kurtIter(end) is the
final kurtosis, ie. the summed kurtosis of each y_final
column of y_final. sum(kurtosis(each column of y_final))

% -------- 1d deconvolution example ------
n = 0:999;
x = [sin(n/30) + 0.2*(mod(n,21)==0)];
[y_final f_final kurt] = med2d(x',30,100,[],'valid',1);

% -------- 2d deconvolution example ------
% This will mostly extract the impulse-like
% disturbances caused by 0.2*(mod(n,21)==0)
% and plot the result.
n = 0:999;
x = [sin(n/30) + 0.2*(mod(n,21)==0);
sin(n/13) + 0.2*(mod(n,21)==0)];
[y_final f_final kurt] = med2d(x',30,100,[],'valid',1);

The solution is not guaranteed to be the optimal solution to the
entropy minimizataion problem, the solution is just a local
minimum of the entropy and therefore a good pick.

Cite As

Geoff McDonald (2021). med2d(x,filterSize,termIter,termDelta,overlapMode,plotMode) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

Zhiyuan HE

Randall SONG

lewei yan

xingwei zhao


MED is a terrific algorithm and the author has made a very good job.

However, I found that improvement might be needed when dealing with large data or filter kernel. In such cases, calculation the cross-correlation using for-loop is extremely slow.

To improve, I used FFT-based cross correlation and the speed was hundred times faster. Anyone interested might look into Matlab's function xcorr.m and make your own improvement.

Santhana Raj

Good work....But I don understand why the author didnt use already existing functions like autocorr, corr, kurtosis and all... this implementation takes more time to execute...

Geoff McDonald

I just thought I would note that the Stat toolbox is not needed anymore. I updated this to implement the kurtosis() function internally.

Geoff McDonald

Thanks Bruno. I forgot the kurtosis() function was from the statistical toolbox. I will update the description to include it as a requirement, or just code the kurtosis function myself.

Bruno Luong

It seems the function requires Stat toolbox and or signal processing toolbox. Author should mention the requirement.

Geoff McDonald

If anyone would like the 2D MED implementation, just let me know and I will work on adding it to this file. I don't need the 2d approach for my work, and I want to make sure someone else would get use out of the extension before working at.

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

Community Treasure Hunt

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

Start Hunting!