Be the first to rate this file! 19 downloads (last 30 days) File Size: 2.72 KB File ID: #18551

Running Extrema

by Dan Kominsky

 

31 Jan 2008 (Updated 25 Jun 2008)

Code covered by BSD License  

Returns the running minimum or maximum of a vector or matrix (analagous to the running average)

Download Now | Watch this File

File Information
Description

Given a set of data, this function is intended to return an output of the same size which gives the lowest (or highest) values which are present within the specified window size. Algorithm is *much* faster than sequential calls to min with reduced ranges, at least for large data sets.

% runningmin - Computes a running extreme of an input vector or matrix
% Optional file header info (to give more details about the function than in the H1 line)
% Syntax: out = runningmin(input,nSamples,type)
% input - vector or matrix of data to return the running min or max from
% nSamples - The size of the window to check for mins or maxes
% type - 'min','max', or 'both' (default) which type of extremes to return
% out - running minimum or maximum requested. If both minimum is returned
% first, then maximum
% Example
% [runMin,runMax] = runningExtreme(data,31,'both')
%
% Subfunctions: fillIn
% See also: min, max, sort

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
25 Jun 2008

Switched to the much faster 1-D Van Herk Algorithm. According to theory uses 3 comparisons per data point, no matter the size of the filter.

Tag Activity for this File
Tag Applied By Date/Time
matrices Dan Kominsky 22 Oct 2008 09:45:39
minima Dan Kominsky 22 Oct 2008 09:45:39
maxima Dan Kominsky 22 Oct 2008 09:45:39
extrema Dan Kominsky 22 Oct 2008 09:45:39
window Dan Kominsky 22 Oct 2008 09:45:39
moving Dan Kominsky 22 Oct 2008 09:45:39
running Dan Kominsky 22 Oct 2008 09:45:39
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com