View Raw SPL
/*****************************************************************************
*                                                                            *
*   BLOCKMIN.SPL Copyright (C) 2014 DSP Development Corporation              *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    non-overlapping block minimum                               *
*                                                                            *
*   Revisions:   13 May 2014  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/


#if @HELP_BLOCKMIN

    BLOCKMIN

    Purpose: Computes a moving non-overlapping block minimum of a series.

    Syntax:  BLOCKMIN(s, n)

               s - A series, the input data.

               n - An integer, the block size to find the minimum.

    Returns: A series, the N point moving block minimum.

    Example:
             W1: 1..12
             W2: blockmin(w1, 2)

             W2 == {1, 3, 5, 7, 9, 11}

    Example:
             W3: 1..12
             W4: blockmin(w1, 3)

             W4 == {1, 4, 7, 10}

    Remarks:
             BLOCKMIN computes the N point non-overlapping block minimum of
             a series. 

             If the block size is not an integral fraction of the
             series length, the end points are not processed.

             See XBLOCKMIN to specify the block size as a duration.

    See Also:
             Blockavg
             Blockmax
             Decimate
             Movmin
             Xblockmin
#endif


/* N point block minimum */
blockmin(s, n, flag1 = "", flag2 = "", flag3 = "")
{
        local y;

        if (argc < 2)
        {
                error(sprintf("%s - input series and integer blocksize required", __FUNC__));
        }

        /* decimate the N point moving minimum starting at the Nth sample */
        y = movminimum(s, n, n, n, flag1, flag2);

        return(y);
}