%% DCT Orthogonality
% Verify that the different variants of the discrete cosine transform are orthogonal, using a random signal as a benchmark.
% Start by generating the signal.

s = randn(1000,1);

%
% Verify that DCT-1 and DCT-4 are their own inverses.

dct1 = dct(s,'Type',1);
idt1 = idct(s,'Type',1);

max(abs(dct1-idt1))

dct4 = dct(s,'Type',4);
idt4 = idct(s,'Type',4);

max(abs(dct4-idt4))

%
% Verify that DCT-2 and DCT-3 are inverses of each other.

dct2 = dct(s,'Type',2);
idt2 = idct(s,'Type',3);

max(abs(dct2-idt2))

dct3 = dct(s,'Type',3);
idt3 = idct(s,'Type',2);

max(abs(dct3-idt3))

% Copyright 2012 The MathWorks, Inc.