# dsp.Window

Apply window to input signal

## Description

The `Window` object applies a window to an input signal.

To apply a window to an input signal:

1. Create the `dsp.Window` object and set its properties.

2. Call the object with arguments, as if it were a function.

## Creation

### Syntax

``win = dsp.Window``
``win = dsp.Window(WINDOW)``
``win = dsp.Window(WINDOW,Name,Value)``

### Description

````win = dsp.Window` returns a window object, `win`, that applies a Hamming window with symmetric sampling.```
````win = dsp.Window(WINDOW)` returns a window object with the `WindowFunction` property set to `WINDOW`.```

example

````win = dsp.Window(WINDOW,Name,Value)` returns a window object with the `WindowFunction` property set to `WINDOW` and with other specified properties set to the specified values.```

## Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the `release` function unlocks them.

If a property is tunable, you can change its value at any time.

Specify the type of window to apply. If you run this object in simulation, this property is tunable. When you generate code from a function or script that contains this object and run the generated code, this property is not tunable.

Tunable: Yes

Set this property to `true` to output the window weights. The weights are an M-by-1 vector with M equal to the first dimension of the input.

Specify the level of stopband attenuation in decibels, specified as a nonnegative scalar.

Tunable: Yes

#### Dependencies

This property only applies when the `WindowFunction` property is `'Chebyshev'`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Specify the Kaiser window parameter as a real number. Increasing the absolute value of `Beta` widens the mainlobe and decreases the amplitude of the window sidelobes in the window's frequency magnitude response.

Tunable: Yes

#### Dependencies

This property only applies when `WindowFunction` property is `'Kaiser'`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Specify the number of constant sidelobes as an integer greater than zero.

Tunable: Yes

#### Dependencies

This property only applies when `WindowFunction` property is `'Taylor'`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Specify, in decibels, the maximum sidelobe level relative to the mainlobe as a real number less than or equal to zero. The default is –30, which produces sidelobes with peaks 30 dB down from the mainlobe peak.

Tunable: Yes

#### Dependencies

This property only applies when `WindowFunction` property is `'Taylor'`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Specify the window sampling for generalized-cosine windows as `'Symmetric'` or `'Periodic'`. If you run this object in simulation, this property is tunable. When you generate code from a function or script that contains this object, and run the generated code, this property is not tunable.

Tunable: Yes

#### Dependencies

This property only applies when `WindowFunction` property is `'Blackman'`, `'Hamming'`, `'Hann'`, or `'Hanning'`.

### Fixed-Point Properties

Specify whether to use full precision rules. If you set `FullPrecisionOverride` to `true`, which is the default, the object computes all internal arithmetic and output data types using full precision rules. These rules provide the most accurate fixed-point numerics. It also turns off the display of other fixed-point properties because they do not apply individually. These rules guarantee that no quantization occurs within the object. Bits are added, as needed, to ensure that no roundoff or overflow occurs. If you set `FullPrecisionOverride` to `false`, fixed-point data types are controlled through individual fixed-point property settings. For more information, see Full Precision for Fixed-Point System Objects.

Specify the rounding method.

#### Dependencies

This property applies only if the object is not in full precision mode.

Specify the overflow action.

#### Dependencies

This property applies only if the object is not in full precision mode.

Specify the window fixed-point data type.

Specify the window fixed-point type as a `numerictype` (Fixed-Point Designer) object with a `Signedness` of `Auto`.

#### Dependencies

This property applies when you set the `WindowDataType` property to `'Custom'`.

Specify the product fixed-point data type as one of ```'Full precision'```, `'Same as input'`, or `'Custom'`.

Specify the product fixed-point type as a scaled `numerictype` (Fixed-Point Designer) object with a `Signedness` of `Auto`.

#### Dependencies

This property applies when you set the `ProductDataType` property to `'Custom'`.

Specify the output fixed-point data type as one of ```'Same as product'```, `'Same as input'`, `'Custom'`.

Specify the output fixed-point type as a `numerictype` (Fixed-Point Designer) object with a `Signedness` of `Auto`.

#### Dependencies

This property applies when you set the `OutputDataType` property to `Custom`.

## Usage

### Syntax

``Y = win(X)``
``[Y,W] = win(X)``

### Description

````Y = win(X)` generates the windowed output, `Y`, of the input, `X`, using the specified window.```

example

````[Y,W] = win(X)` returns the window values `W` when the `WeightsOutputPort` property is `true`.```

### Input Arguments

expand all

Data input, specified as a vector or a matrix.

This object supports only frame-based processing. To see the effect of the window, the data must have a frame size of at least 2 in each channel.

When the input is fixed-point, it must be signed fixed point with power-of-two slope and zero bias.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `fi`
Complex Number Support: Yes

### Output Arguments

expand all

Windowed output, returned as vector or a matrix.

When the input is an integer, the word length and fraction length of the output, `Y` is calculated using the following:

`$\begin{array}{l}{Y}_{\text{WL}}=2{X}_{\text{WL}}\\ {Y}_{\text{FL}}={X}_{\text{WL}}+{X}_{\text{FL}}-1\end{array}$`

where,

• YWL –– Output word length.

• YFL –– Output fraction length.

• XWL –– Input word length.

• XFL –– Input fraction length. In case of signed integers, this value is 0.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `fi`
Complex Number Support: Yes

Window values, returned as a column vector. The number of elements in the column vector is equal to the frame size (number of rows) of the input signal.

When the input is an integer, the word length and fraction length of the output, `W` is calculated using the following:

`$\begin{array}{l}{W}_{\text{WL}}={X}_{\text{WL}}\\ {W}_{\text{FL}}={Y}_{\text{FL}}-{X}_{\text{FL}}\end{array}$`

where,

• WWL –– Window word length.

• WFL –– Window fraction length.

• YFL –– Output fraction length.

• XFL –– Input fraction length. In case of signed integers, this value is 0.

#### Dependencies

This output appears only when the `WeightsOutputPort` property is set to `true`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `fi`

## Object Functions

To use an object function, specify the System object™ as the first input argument. For example, to release system resources of a System object named `obj`, use this syntax:

`release(obj)`

expand all

 `step` Run System object algorithm `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset internal states of System object

## Examples

collapse all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent `step` syntax. For example, myObject(x) becomes step(myObject,x).

```win = dsp.Window( ... 'WindowFunction','Hamming', ... 'WeightsOutputPort',true); x = rand(64,1); [y,w] = win(x);```

View the window's time and frequency domain responses

`wvtool(w)`

## Algorithms

This object implements the algorithm, inputs, and outputs described on the Window Function block reference page. The object properties correspond to the block parameters, except:

• Operation — The `dsp.Window` object does not support the `Generate window` option.

• Operation — The ```Generate and apply window``` option on the block corresponds to the `WeightsOutputPort` property set to `true` on the `dsp.Window` object.

• The `dsp.Window` object only supports frame-based processing.

## Extended Capabilities

### Objects

Introduced in R2012a

Watch now