Last Modified: March 15, 2017

Computes the Discrete Cosine Transform (DCT) of a sequence.

A real vector.

This input can be a 1D or 2D array of double-precision, floating-point numbers.

The length of the DCT you want to perform.

If **DCT size** is greater than the number of elements in **x**, this node adds zeros to the end of **x** to match the size of **DCT size**. If **DCT size** is less than the number of elements in **x**, this node uses only the leading **DCT size** elements in **x** to perform the DCT. If **DCT size** is less than or equal to zero, this node uses the length of **x** as the **DCT size**.

This input is available only if you wire a 1D array of double-precision, floating-point numbers to **x**.

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an **error in** input and an **error out** output so that the node can respond to and communicate errors that occur while code is running. The value of **error in** specifies whether an error occurred before the node runs. Most nodes respond to values of **error in** in a standard, predictable way.

**Default: **No error

The DCT of the input sequence.

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

**error in** input and an **error out** output so that the node can respond to and communicate errors that occur while code is running. The value of **error in** specifies whether an error occurred before the node runs. Most nodes respond to values of **error in** in a standard, predictable way.

The one-dimensional Discrete Cosine Transform **DCT{x}** of a 1D array **x** is defined by the following equations:

${y}_{k}=\sqrt{\frac{2}{N}}{\alpha}_{k}\underset{n=0}{\overset{N-1}{\sum}}{x}_{n}\cdot \mathrm{cos}\frac{(2n+1)k\pi}{2N}$

and

${\alpha}_{k}=\{\begin{array}{c}\frac{1}{\sqrt{2}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}k=0\\ 1\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}k=1,\text{\hspace{0.17em}}2,\text{\hspace{0.17em}}\mathrm{...},\text{\hspace{0.17em}}N-1\end{array}$

where

*N*is the length of**x***y*_{k}is the*k*^{th}element of**DCT{x}***x*_{n}is the*n*^{th}element of**x**

This node applies a fast DCT algorithm instead of calculating the Discrete Cosine Transform directly. This node implements the fast DCT algorithm using an FFT-based technique.

The two-dimensional Discrete Cosine Transform **DCT{x}** of a 2D array **x** is defined by the following equation:

$y(u,v)=\sqrt{\frac{2}{M}}\sqrt{\frac{2}{N}}{\alpha}_{u}{\alpha}_{v}\underset{m=0}{\overset{M-1}{\sum}}\underset{n=0}{\overset{N-1}{\sum}}x(m,n)\mathrm{cos}\frac{(2m+1)u\pi}{2M}\mathrm{cos}\frac{(2n+1)v\pi}{2N}$

where

*M*is the number of rows of**x***N*is the number of columns of**x**- x(m, n) is the element of
**x**with row number*m*and column number*n* - y(u, v) is the element of
**DCT{x}**with row number*u*and column number*v*

This node performs a two-dimensional DCT using the following two steps:

**Where This Node Can Run: **

Desktop OS: Windows

FPGA: This product does not support FPGA devices