%% DCT transform
% Tom Wada
% 2011/6/27

N=8;
n=(0:N-1);
%基底関数
p=zeros(N,N);
p(1,:)=1*cos(pi/(2*N)*(2*n+1)*0);
for l=2:N
    p(l,:)=sqrt(2)*cos(pi/(2*N)*(2*n+1)*(l-1));
end

%% 基底関数
p
%%入力
AA=[1 2 3 4 5 6 7 8]'
%% 教科書のDCT
textdct=p*AA/8
%%　MATLAB DCT
matdct=dct(AA)
%% MATLAB　DCTを自分の基底関数で再現
handmatdct=p*AA/sqrt(8)

