View Raw SPL
/*****************************************************************************
*                                                                            *
*   TAYLORWIN.SPL  Copyright (C) 2011 DSP Development Corporation            *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Multiplies a series with a Taylor window                    *
*                                                                            *
*   Revisions:   20 Dec 2011  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/


#if @HELP_TAYLORWIN

    TAYLORWIN

    Purpose: Multiplies a series with a Taylor window.

    Syntax:  TAYLORWIN(s, nbar, attn)

                    s  - A series, the input series.

                  nbar - Optional. A positive integer, the number of
                         approximate constant level sidelobes adjacent to 
                         the mainlobe. Defaults to 4.

                  attn - Optional. A negative real, the sidelobe attenuation
                         in dB from the mainlobe. Defaults to -30.

    Returns: A series.

    Example:
             W1: gsin(1000, 0.001, 45)
             W2: taylorwin(w1)

             W1 contains a 1000 point sinewave with a frequency of 45 Hz.
             W2 multiplies the sinewave with a Taylor window.

    Example:
             W1: gsin(1000, 0.001, 45)
             W2: taylorwin(w1, 5, -35)

             Same as the first example except the number of approximately
             constant sidelobes is 5 and the sidelobe attenuation is -35 dB.

    Example:
             W1: taylorwin(100, 5, -35)
             W2: magspec(w1, 8192);20*log10(curr/max(curr))

             W1 creates a 100 point Taylor window where the number of
             approximately constant level sidelobes is 5 and the
             sidelobe attenuation is -35 dB. W2 displays the frequency
             response.

    Example:
             taylorwin(100, 5, -35)

             Creates a 100 point Taylor window where the number of
             approximately constant level sidelobes is 5 and the
             sidelobe attenuation is -35 dB.

    Remarks:
             Taylor windows are similar to Dolph-Chebyshev windows. 
             The Taylor window approximates the minimization of the
             main lobe width in the Dolph-Chebyshev window, but allows
             the sidelobe levels to decrease beyond a certain
             frequency.

             Because the Taylor distribution avoids edge
             discontinuities, the window sidelobes decrease
             monotonically.

             The Taylor window coefficients are not normalized.

             Taylor windows are typically used in radar applications,
             such as weighting synthetic aperture radar images,
             circular array antennas and antenna design.

             NBAR is the number of approximately equal sidelobes adjacent
             to the mainlobe and should satisfy:

               NBAR >= 2 * A^2 + 0.5 

             where
             
               A = acosh(10^(attn / 20)) / pi

             otherwise the sidelobe level specified is not guaranteed.

             The attn parameter specifies the maximum sidelobe level in
             dB relative to the mainlobe level.

             If the input is an integer with a value of N, an N point
             Taylor window is returned. See GTAYLORWIN to also create
             an N point Taylor window.

             See CHEBWIN to create a Dolph-Chebyshev window.

    See Also:
             CHEBWIN
             FFT
             GTAYLORWIN
             HAMMIMG
             HANNING
             KAISER
             PSD
             SPECTRUM
#endif


/* multiply a series with a Taylor window */
SERIES taylorwin(s, ampflag, nbar, attn)
{
        if (argc < 4)
        {
                if (argc < 3)
                {
                        if (argc < 2)
                        {
                                if (argc < 1) error("taylorwin - input required");

                                ampflag = 0;
                        }

                        nbar = 4;
                }

                attn = -30;
        }

        return(winfunc(8, s, ampflag, nbar, attn));
}