Compute and apply window to input signal
DSP System Toolbox / Signal Operations
The Window Function block has three modes of operation that enable you to apply a window, or compute a window, or compute and apply a window to an input signal. You can select the mode 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.
In
— Input signalInput signal, specified as a vector, matrix, or an ND array. When the input is fixed point, it can be signed only.
This port is enabled only when you set Operation to either
Apply window to input
or Generate and apply
window
.
This port is unnamed when you set Operation to
Apply window to input
.
Data Types: single
 double
 int8
 int16
 int32
 fixed point
Out
— OutputOutput signal, returned as a vector, matrix, or an ND array.
The Out port is enabled only when Operation is set to:
Apply window to input
–– The block computes an
Mby1 window vector w and applies it to
the MbyN input, where
M is the number of rows in the input signal.
Generate and apply window
–– The block generates
an Mby1 window vector w and applies it
to the input.
The output signal has the same dimensions as the input signal. For more details, see Operation.
Data Types: single
 double
 int8
 int16
 int32
 fixed point
Win
— Window outputWindow output, returned as a vector. When Operation is set to
Apply window to input
or Generate and apply
window
, the window vector is of the same length as the number of rows
in the input signal. When Operation is set to
Generate window
, the length of window vector is
determined by the Window length parameter.
Data Types: single
 double
 int8
 int16
 int32
 fixed point
Operation
— Modes of operationApply window to input
(default)  Generate window
 Generate and apply window
The Window Function block has three modes of operation that you can select through 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 Mby1 window vector w and applies it to the input. The output y always has the same dimension as the input.
When the input is an MbyN matrix u, the window is multiplied elementwise 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
The window is always applied to the first dimension:
$$y(i,j,\mathrm{...},k)=w(i)*u(i,j,\mathrm{...},k)\text{}i=1,\mathrm{...},M,\text{}j=1,\mathrm{...},N,\text{}\mathrm{...},\text{}k=1,\mathrm{...},P$$
A lengthM unoriented vector input is treated as an Mby1 vector.
Generate window
In this mode, the block generates an unoriented 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 Mby1 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.
At the Win port, the block produces the Mby1 window vector w.
When the input is an MbyN matrix u, the window is multiplied elementwise 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
The window is always applied to the first dimension:
$$y(i,j,\mathrm{...},k)=w(i)*u(i,j,\mathrm{...},k)\text{}i=1,\mathrm{...},M,\text{}j=1,\mathrm{...},N,\text{}\mathrm{...},\text{}k=1,\mathrm{...},P$$
A lengthM 1D vector input is treated as an Mby1 vector.
Window type
— Type of windowHamming
(default)  Bartlett
 Blackman
 ...This table lists the available window types.
Window Type  Description 

Bartlett  Computes a Bartlett window. w = 
Blackman  Computes a Blackman window. w = 
Boxcar  Computes a rectangular window. w = 
Chebyshev  Computes a Chebyshev window with stopband ripple
w = 
Hamming  Computes a Hamming window. w = 
Hann  Computes a Hann window (also known as a Hanning window). w = 
Hanning  Obsolete. This window type is included only for compatibility
with older models. Use the 
Kaiser  Computes a Kaiser window with the Kaiser parameter
w = 
Taylor  Computes a Taylor window. w = 
Triang  Computes a triangular window. w = 
User Defined  Computes the userdefined window function specified by the entry
in the Window function name parameter,
w = usrwin(M) % Window takes no extra parameters w = usrwin(M,x_{1},...,x_{n}) % Window takes extra parameters {x_{1} ... x_{n}} 
Sampling
— Type of samplingSymmetric
(default)  Periodic
Specify the window sampling for generalizedcosine windows.
For the generalizedcosine 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)
Tunable (Simulink) in simulation only.
This parameter is visible only when you select
Blackman
, Hamming
,
Hann
, or Hanning
for the
Window type parameter.
Sample mode
— Sample modeContinuous
(default)  Discrete
Specify the sample mode for the block, Continuous
or
Discrete
, when it is in the Generate
window
mode. In the Apply window to input
and Generate and apply window
modes, the block inherits the
sample mode from its driving block.
This parameter is visible only when you select Generate
window
for the Operation parameter.
Sample time
— Sample time1
(default)  real scalarSpecify the sample time for the block when Operation is set
to Generate window
and Sample mode is
set to Discrete
. When Operation is set
to Apply window to input
and Generate and
apply window
, the block inherits the sample time from its driving
block.
This parameter is visible only when you set Sample mode to
Discrete
.
Window length
— Length of window64
(default)  positive integerSpecify the length of the window to apply.
This parameter is visible only 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.
Stopband attenuation in dB
— Stopband attenuation in dB50
(default)  nonnegative scalarSpecify the level of stopband attenuation R_{s} in decibels.
Tunable (Simulink) in simulation only.
This parameter is visible only when you select
Chebyshev
for the Window type
parameter.
Beta
— Kaiser window β parameter10
(default)  real scalarSpecify the Kaiser
window β
parameter. Increasing β widens the mainlobe and decreases the
amplitude of the window sidelobes in the window's frequency magnitude response.
Tunable (Simulink) in simulation only.
This parameter is visible only when you select Kaiser
for the Window type parameter.
Number of sidelobes
— Number of sidelobesSpecify the number of sidelobes as a scalar integer value greater than zero.
This parameter is visible only when you select Taylor
for the Window type parameter.
Maximum sidelobe level relative to mainlobe (dB)
— Maximum sidelobe level relative to mainlobe30
(default)  scalar less than or equal to zeroSpecify 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 visible only when you select Taylor
for the Window type parameter.
Window function name
— Window function namehamming
(default)  character vectorSpecify the name of the userdefined window function to be calculated by the
block. The output window vector returned by the custom window function must be of data
type double
.
This parameter is visible only when you select User
defined
for the Window type parameter.
Specify additional arguments to the hamming function
— Specify additional arguments to the window functionSelect to enable the Cell array of additional arguments parameter, when the userdefined window requires parameters other than the window length.
This parameter is visible only when you select User
defined
for the Window type parameter.
Cell array of additional arguments
— Additional arguments{'symmetric'}
(default)  cell arraySpecify the extra parameters required by the userdefined 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.
When the Operation parameter on the Main tab
is set to Generate window
, the following parameters
appear.
Window data type
— Window data typedouble
(default)  single
 Fixedpoint
 Userdefined
 Inherit via back propagation
Specify the window data type in one of the following ways:
double
single
Fixedpoint
–– To specify the window data type
and scaling in the Signed, Word
length, Set fraction length in output to, and
Fraction length parameters.
Userdefined
–– To specify the window data type
and scaling in the Userdefined data type, Set
fraction length in output to, and Fraction
length parameters.
Inherit via back propagation
–– To set the window
data type and scaling to match the following block.
Signed
— Window output is signedSelect to output a signed fixedpoint signal. Otherwise, the signal is unsigned.
This parameter appears only when you set Window data type
to Fixedpoint
.
Word length
— Word length16
(default)  positive integer in the range [2 128]Specify the word length of the fixedpoint window data type in bits.
This parameter is visible only when you set Window data
type to Fixedpoint
.
Userdefined data type (e.g. sfix(16), float('single))
— userdefined data typesfix(16)
(default)  builtin data type  fixedpoint data typeSpecify any builtin or fixedpoint data type. You can specify fixedpoint data
types using the FixedPoint Designer™ functions sfix
(Simulink), ufix
(Simulink), sint
(Simulink), uint
(Simulink), sfrac
(Simulink), and ufrac
(Simulink).
This parameter is only visible when you set Window data
type to Userdefined
.
Set fraction length in output to
— Scaling of fixedpoint window data typeBest precision
(default)  Userdefined
Specify the scaling of the fixedpoint window data type by using either of these methods:
Choose Best precision
to have the window data
type scaling automatically set such that the output signal has the best possible
precision.
Choose Userdefined
to specify the window data
type scaling in the Fraction length parameter.
This parameter is visible only when you set Window data
type to Fixedpoint
or
Userdefined
, and when the specified window data type
is a fixedpoint data type.
Fraction length
— Userdefined fraction length15
(default)  integerSpecify the fraction length of the fixedpoint window data type in bits.
This parameter is visible only when you set Window data
type to Fixedpoint
or
Userdefined
, and when you set Set fraction
length in output to to Userdefined
.
When the Operation parameter on the Main tab
is set to either Apply window to input
or Generate
and apply window
, the following parameters appear.
Rounding mode
— Rounding modeFloor
(default)  Ceiling
 Convergent
 Nearest
 Round
 Simplest
 Zero
Select the rounding mode for fixedpoint operations.
The window vector w does not obey this parameter. It always
rounds to Nearest
.
Note
The Rounding mode and Overflow mode settings have no effect on numerical results when both of these conditions exist:
Product output is Inherit via internal
rule
Output is Same as product
output
With these data type settings, the block is effectively operating in a fullprecision mode.
Overflow mode
— Overflow modeWrap
(default)  Saturate
Select the overflow mode for fixedpoint operations.
The window vector w does not obey this parameter. It is always saturated.
Window
— Window data typeSame word length as input
(default)  Specify word length
 Binary point scaling
 Slope and bias scaling
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.
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.
Binary point scaling
–– You can enter the word
length and the fraction length of the window vector elements in bits.
Slope and bias scaling
–– You can enter the word
length, in bits, and the slope of the window vector elements. This block
requires poweroftwo 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
.
Product output
— Product output data typeInherit via internal rule
(default)  Same as input
 Binary point scaling
 Slope and bias scaling
Use this parameter to specify how you want to designate the product output word and fraction lengths.
When you select:
Inherit via internal rule
–– The product output
word length and fraction length are calculated automatically. For information on
how the product output word and fraction lengths are calculated when an internal
rule is used, see Inherit via Internal Rule.
Same as input
–– These characteristics match
those of the input to the block.
Binary point scaling
–– You can enter the word
length and the fraction length of the product output in bits.
Slope and bias scaling
–– You can enter the word
length in bits and the slope of the product output. This block requires
poweroftwo slope and a bias of zero.
Output
— Output data typeSame as product output
(default)  Same as input
 Binary point scaling
 Slope and bias scaling
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.
Same as input
–– These characteristics match
those of the input to the block.
Binary point scaling
–– You can enter the word
length and the fraction length of the output in bits.
Slope and bias scaling
–– You can enter the word
length in bits and the slope of the output. This block requires poweroftwo
slope and a bias of zero.
Lock data type settings against changes by the fixedpoint tools
— Prevent fixedpoint tools from overriding data typesoff
(default)  on
Select this parameter to prevent the fixedpoint tools from overriding the data types you specify on the block dialog.
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

Generated code relies on memcpy
or
memset
functions (string.h
) under certain
conditions.
If the input is fixed point, it must be signed integer or signed fixed point with poweroftwo slope and zero bias.
The following diagram shows the data types used within the Window Function block for fixedpoint signals for each of the three operating modes.
You can set the window, product output, and output data types in the block dialog box.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.