From: Bruno Luong on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hfbmmk$p0o$1(a)fred.mathworks.com>...
> Please take a look at this function. Mex setup is required, but it will be hard to beat the speed performance
>
> http://www.mathworks.com/matlabcentral/fileexchange/24705-minmax-filter
>
> Bruno

Here is how you use it:

% Data
A=rand(1,70000);

% Engine
tic
win=1000;
Amin = minmaxfilt(A,win,'min','same');
toc

On my computer it takes about 4 ms to run the filter on 70000 data points.

Note that MINMAXFILT can work on array as well:

A=rand(70000,10);

% Take the moving min along the first dimension
tic
win=1000;
Amin = minmaxfilt(A,[win 1],'min','same');
toc % 0.030306 seconds.

Bruno