| Signal Processing Blockset™ | ![]() |
Transforms
dspxfrm3
The DCT block computes the unitary discrete cosine transform (DCT) of each channel in the M-by-N input matrix, u.
y = dct(u) % Equivalent MATLAB code
When the input is a sample-based row vector, the DCT block computes the discrete cosine transform across the vector dimension of the input. For all other sample-based N-D arrays, the block computes the DCT across the first dimension of the input.
For both sample-based and frame-based inputs, the block assumes that each input column is a frame containing M consecutive samples from an independent channel. The frame size, M, must be a power of two. To work with other frame sizes, use the Pad block to pad or truncate the frame size to a power-of-two length.
When the input is an M-by-N matrix, the DCT block outputs an M-by-N matrix whose lth column contains the length-M DCT of the corresponding input column.

where

The output is always sample based, and the output port rate and data type (real/complex) are the same as those of the input port.
For convenience, length-M 1-D vector inputs and sample-based length-M row vector inputs are processed as single channels (that is, as M-by-1 column vectors), and the output has the same dimension as the input.
The Sine and cosine computation parameter determines how the block computes the necessary sine and cosine values. This parameter has two settings, each with its advantages and disadvantages, as described in the following table.
Sine and Cosine Computation Parameter Setting | Sine and Cosine Computation Method | Effect on Block Performance |
|---|---|---|
Table lookup | The block computes and stores the trigonometric values before the simulation starts, and retrieves them during the simulation. When you generate code from the block, the processor running the generated code stores the trigonometric values computed by the block in a speed-optimized table, and retrieves the values during code execution. | The block usually runs much more quickly, but requires extra memory for storing the precomputed trigonometric values. |
Trigonometric fcn | The block computes sine and cosine values during the simulation. When you generate code from the block, the processor running the generated code computes the sine and cosine values while the code runs. | The block usually runs more slowly, but does not need extra data memory. For code generation, the block requires a support library to emulate the trigonometric functions, increasing the size of the generated code. |
This block supports Simulink virtual buses.
The following diagrams show the data types used within the DCT block for fixed-point signals. You can set the sine table, accumulator, product output, and output data types displayed in the diagrams in the DCT block dialog as discussed in Dialog Box.
Inputs to the DCT block are first cast to the output data type and stored in the output buffer. Each butterfly stage processes signals in the accumulator data type, with the final output of the butterfly being cast back into the output data type.

The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types.
The Main pane of the DCT block dialog appears as follows.

Sets the block to compute sines and cosines by either looking up sine and cosine values in a speed-optimized table (Table lookup), or by making sine and cosine function calls (Trigonometric fcn). See the previous table.
The Fixed-point pane of the DCT block dialog appears as follows.

Select the rounding mode for fixed-point operations. The sine table values do not obey this parameter; they always round to Nearest.
Select the overflow mode for fixed-point operations.
Choose how you specify the word length of the values of the sine table. The fraction length of the sine table values is always equal to the word length minus one:
When you select Same word length as input, the word length of the sine table values match that of the input to the block.
When you select Specify word length, you can enter the word length of the sine table values, in bits.
The sine table values do not obey the Rounding mode and Overflow mode parameters; they are always saturated and rounded to Nearest.
Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication 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.
Use this parameter to specify how you would like to designate the accumulator word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the accumulator data type in this block:
When you select Inherit via internal rule, the accumulator word length and fraction length are calculated automatically. For information about how the accumulator word and fraction lengths are calculated when an internal rule is used, see Inherit via Internal Rule.
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 accumulator, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.
Choose how you specify the output word length and fraction length:
When you select Inherit via internal rule, the output word length and fraction length are calculated automatically. The internal rule first calculates an ideal output word length and fraction length using the following equations:
![]()
![]()
Using these ideal results, the internal rule then selects word lengths and fraction lengths that are appropriate for your hardware. For more information, 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 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 |
|
| Complex Cepstrum | Signal Processing Blockset |
| FFT | Signal Processing Blockset |
| IDCT | Signal Processing Blockset |
| Real Cepstrum | Signal Processing Blockset |
| dct | Signal Processing Toolbox |
![]() | dB Gain | Delay | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |