| Signal Processing Blockset™ | ![]() |
Signal Operations
dspsigops

The Window Function block computes a window and/or applies a window to an input signal. The input signal can be a frame-based matrix, or a sample-based N-D array. The Window Function block supports real and complex floating-point and fixed-point inputs.
The Window Function block has three modes of operation that you can select via the Operation parameter. In each mode, the block first creates a window vector w by sampling the window specified in the Window type parameter at M discrete points. The operation modes are:
Apply window to input
In this mode, the block computes an M-by-1 window vector w and applies it to the input. The output y always has the same dimension as the input. When the input is frame based, the output is frame based; otherwise, the output is sample based.
When the input is an M-by-N matrix u, the window is multiplied element-wise with each of the N channels in the input matrix u. This is equivalent to the following MATLAB code:
y = repmat(w,1,N) .* u % Equivalent MATLAB code
When the input is a sample-based N-D array, the window is always applied to the first dimension:
![]()
A length-M 1-D vector input is treated as an M-by-1 matrix.
Generate window
In this mode, the block generates a sample-based 1-D window vector w with length M specified by the Window length parameter. The In port is disabled for this mode.
Generate and apply window
In this mode, the block generates an M-by-1 window vector w and applies it to the input. The block produces two outputs:
At the Out port, the block produces the result of the multiplication y, which has the same dimension as the input. When the input is frame based, the output y is frame based; otherwise, the output y is sample based.
At the Win port, the block produces the M-by-1 window vector w. The output vector w is always sample based.
When the input is an M-by-N matrix u, the window is multiplied element-wise with each of the N channels in the input matrix u. This is equivalent to the following MATLAB code:
y = repmat(w,1,N) .* u % Equivalent MATLAB code
When the input is a sample-based N-D array, the window is always applied to the first dimension:
![]()
A length-M 1-D vector input is treated as an M-by-1 matrix.
The following table lists the available window types. For complete information about the window functions, consult the Signal Processing Toolbox documentation.
| Window Type | Description |
|---|---|
Computes a Bartlett window. w = bartlett(M) | |
Computes a Blackman window. w = blackman(M) | |
Computes a rectangular window. w = rectwin(M) | |
Computes a Chebyshev window with stopband ripple R. w = chebwin(M,R) | |
Computes a Hamming window. w = hamming(M) | |
Computes a Hann window (also known as a Hanning window). w = hann(M) | |
Hanning | Obsolete. This window type is included only for compatibility with older models. Use the Hann Window type instead of Hanning whenever possible. |
Computes a Kaiser window with the Kaiser parameter beta. w = kaiser(M,beta) | |
Computes a Taylor window. w = taylorwin(M) | |
Computes a triangular window. w = triang(M) | |
User Defined | Computes the user-defined window function specified by the entry in the Window function name parameter, usrwin. w = usrwin(M) % Window takes no extra parameters
w = usrwin(M,x1,...,xn) % Window takes extra
parameters {x1 ... xn}
|
For the generalized-cosine windows (Blackman, Hamming, Hann, and Hanning), the Sampling parameter determines whether the window samples are computed in a periodic or a symmetric manner. For example, when Sampling is set to Symmetric, a Hamming window of length M is computed as
w = hamming(M) % Symmetric (aperiodic) window
When Sampling is set to Periodic, the same window is computed as
w = hamming(M+1) % Periodic (asymmetric) window w = w(1:M)
The following diagram shows the data types used within the Window Function block for fixed-point signals for each of the three operating modes.

You can set the window, product output, and output data types in the block dialog box. For more information see the Dialog Box section.
The following model uses the Window Function block to generate and apply a Hamming window to a sample-based 3-dimensional input array.
In this example, set the Operation mode of the Window Function block to Generate and apply window, so the block provides two outputs: the window vector w at the Win port, and the result of the multiplication y at the Out port.
Open the model by typing doc_windowfunction_ref at the MATLAB command line, and run it.

The length of the first dimension of the input array is 10, so the Window Function block generates and outputs a Hamming window vector of length 10. To see the window vector generated by the Window Function block, type w at the MATLAB command line.
To see the result of the multiplication, type y at the MATLAB command line.
The Main pane of the Window Function block dialog appears as follows.

Specify the block's operation, as discussed in Operation Modes. The port configuration of the block is updated to match the setting of this parameter.
Specify the window type to apply, as listed in Window Type. Tunable in simulation only.
Specify the window sampling for generalized-cosine windows. This parameter is only visible when you select Blackman, Hamming, Hann, or Hanning for the Window type parameter. Tunable in simulation only.
Specify the sample mode for the block, Continuous or Discrete, when it is in Generate Window mode. In the Apply window to output and Generate and apply window modes, the block inherits the sample time from its driving block. Therefore, this parameter is only visible when you select Generate window for the Operation parameter.
Specify the sample time for the block when it is in Generate window and Discrete modes. In Apply window to output and Generate and apply window modes, the block inherits the sample time from its driving block. This parameter is only visible when you select Discrete for the Sample Mode parameter.
Specify the length of the window to apply. This parameter is only visible when you select Generate window for the Operation parameter. Otherwise, the window vector length is computed to match the length of the first dimension of the input.
Specify the level of stopband attenuation, Rs, in decibels. This parameter is only visible when you select Chebyshev for the Window type parameter. Tunable in simulation only.
Specify the Kaiser window β parameter. Increasing β widens the mainlobe and decreases the amplitude of the window sidelobes in the window's frequency magnitude response. This parameter is only visible when you select Kaiser for the Window type parameter. Tunable in simulation only.
Specify the number of sidelobes as a scalar integer value greater than zero. This parameter is only visible when you select Taylor for the Window type parameter.
Specify, in decibels, the maximum sidelobe level relative to the mainlobe. This parameter must be a scalar less than or equal to zero. The default value of –30 produces sidelobes with peaks 30 dB down from the mainlobe peak. This parameter is only visible when you select Taylor for the Window type parameter.
Specify the name of the user-defined window function to be calculated by the block. This parameter is only visible when you select User defined for the Window type parameter.
Select to enable the Cell array of additional arguments parameter, when the user-defined window requires parameters other than the window length. This parameter is only visible when you select User defined for the Window type parameter.
Specify the extra parameters required by the user-defined window function, besides the window length. This parameter is only available when you select the Specify additional arguments to the hamming function parameter. The entry must be a cell array.
The Data types pane of the Window Function block dialog is discussed in the following sections:
Parameters for Generate Window Only Mode
Parameters for Apply Window Modes
The Data types pane of the Window Function block dialog appears as follows when the Operation parameter is set to Generate window.

Specify the output data type in one of the following ways:
Choose double or single from the list.
Choose Fixed-point to specify the output data type and scaling in the Signed, Word length, Set fraction length in output to, and Fraction length parameters.
Choose User-defined to specify the output data type and scaling in the User-defined data type, Set fraction length in output to, and Fraction length parameters.
Choose Inherit via back propagation to set the output data type and scaling to match the following block.
Select to output a signed fixed-point signal. Otherwise, the signal is unsigned.
Specify the word length, in bits, of the fixed-point output data type. This parameter is only visible when you select Fixed-point for the Output data type parameter.
Specify any built-in or fixed-point data type. You can specify fixed-point data types using the Simulink Fixed Point functions sfix, ufix, sint, uint, sfrac, and ufrac. This parameter is only visible when you select User-defined for the Output data type parameter.
Specify the scaling of the fixed-point output by either of the following two methods:
Choose Best precision to have the output scaling automatically set such that the output signal has the best possible precision.
Choose User-defined to specify the output scaling in the Fraction length parameter.
This parameter is only visible when you select Fixed-point or User-defined for the Output data type parameter, and when the specified output data type is a fixed-point data type.
Specify the fraction length, in bits, of the fixed-point output data type. This parameter is only visible when you select Fixed-point or User-defined for the Output data type parameter and User-defined for the Set fraction length in output to parameter.
The Fixed-point pane of the Window Function block dialog appears as follows when the Operation parameter is set to either Apply window to input or Generate and apply window.

Select the rounding mode for fixed-point operations.
The window vector w does not obey this parameter; it always rounds to Nearest.
Select the overflow mode for fixed-point operations.
The window vector w does not obey this parameter; it is always saturated.
Choose how you specify the word length and fraction length of the window vector w.
When you select Same word length as input, the word length of the window vector elements is the same as the word length of the input. The fraction length is automatically set to the best precision possible.
When you select Specify word length, you can enter the word length of the window vector elements in bits. The fraction length is automatically set to the best precision possible.
When you select Binary point scaling, you can enter the word length and the fraction length of the window vector elements in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the window vector elements. This block requires power-of-two slope and a bias of zero.
The window vector does not obey the Rounding mode and Overflow mode parameters; it is always saturated and rounded to Nearest.
Use this parameter to specify how you want to designate the product output word and fraction lengths. See Fixed-Point Data Types for illustrations depicting the use of the product output data type in this block:
When you select Inherit via internal rule, the product output word length and fraction length are calculated automatically. For information about how the product output word and fraction lengths are calculated when an internal rule is used, see Inherit via Internal Rule.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.
Choose how you specify the word length and fraction length of the output of the block:
When you select Same as product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. This block requires power-of-two slope and a bias of zero.
Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling feature of the Fixed-Point Tool. See the fxptdlg reference page for more information.
| Port | Supported Data Types |
|---|---|
Input |
|
Output |
|
Win |
|
| FFT | Signal Processing Blockset |
| bartlett | Signal Processing Toolbox |
| blackman | Signal Processing Toolbox |
| rectwin | Signal Processing Toolbox |
| chebwin | Signal Processing Toolbox |
| hamming | Signal Processing Toolbox |
| hann | Signal Processing Toolbox |
| kaiser | Signal Processing Toolbox |
| taylorwin | Signal Processing Toolbox |
| triang | Signal Processing Toolbox |
![]() | Wavelet Synthesis (Obsolete) | Yule-Walker AR Estimator | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |