dsp.DCT System object

Package: dsp

Discrete cosine transform (DCT)


The DCT object computes the discrete cosine transform (DCT) of input.

To compute the DCT of input:

  1. Define and set up your DCT object. See Construction.

  2. Call step to compute the DCT according to the properties of dsp.DCT. The behavior of step is specific to each object in the toolbox.


H = dsp.DCT returns a discrete cosine transform (DCT) object, H, used to compute the DCT of a real or complex input signal.

H = dsp.DCT('PropertyName',PropertyValue, ...) returns a DCT object, H, with each property set to the specified value.



Method to compute sines and cosines

Specify how the DCT object computes the trigonometric values as Trigonometric function or Table lookup. This property must be set to Table lookup for fixed-point inputs. The default is Table lookup.

 Fixed-Point Properties


cloneCreate discrete cosine transform object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepDiscrete cosine transform (DCT) of input


Use DCT to analyze the energy content in a sequence:

x = (1:128).' + 50*cos((1:128).'*2*pi/40);
hdct = dsp.DCT;
X = step(hdct, x);
% Set the DCT coefficients which represent less 
% than 0.1% of the total energy to 0 and 
% reconstruct the sequence using IDCT. 
[XX, ind] = sort(abs(X),1,'descend');
ii = 1;
while (norm([XX(1:ii);zeros(128-ii,1)]) <= 0.999*norm(XX))
ii = ii+1;
disp(['Number of DCT coefficients that represent 99.9%',...
'of the total energy in the sequence: ',num2str(ii)]); 
XXt = zeros(128,1);
XXt(ind(1:ii)) = X(ind(1:ii));
hidct = dsp.IDCT;
xt = step(hidct, XXt);
plot(1:128,[x xt]);
legend('Original signal','Reconstructed signal',...


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

Introduced in R2012a

Was this topic helpful?