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.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

Creation

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.

For more information on changing property values, see System Design in MATLAB Using System Objects (MATLAB).

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 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 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 object with a Signedness of Auto.

Dependencies

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

Usage

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:

YWL=2XWLYFL=XWL+XFL1

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:

WWL=XWLWFL=YFLXFL

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

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

expand 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

See Also

Functions

System Objects

Introduced in R2012a