%% DFT transform
% Tom Wada
% 2011/6/20

clear all;

% DFT
M=16
n0=0:0.1:7.9;
%婎掙娭悢
y0=zeros(8,8*10);
y0(1,:)=exp(-1j*2*pi*(1-1)*n0/M);
for l=2:8
    y0(l,:)=sqrt(2)*exp(-1j*2*pi*(l-1)*n0/M);
end
y3=zeros(8,8);
x3=0:7;
y3(1,:)=exp(-1j*2*pi*(1-1)*x3/M);
for l=2:8
    y3(l,:)=sqrt(2)*exp(-1j*2*pi*(l-1)*x3/M);
end

%DCT
N=8;
n=0:7;
%婎掙娭悢
y1=zeros(8,8);
x1=n+1/2;
y1(1,:)=1*cos(2*pi/(2*N)*(n+1/2)*0);
for l=2:N
    y1(l,:)=sqrt(2)*cos(2*pi/(2*N)*(n+1/2)*(l-1));
end

%DST
N=8;
n=0:7;
%婎掙娭悢
y2=zeros(8,8);
x2=n+1/2;
y2(1,:)=1*sin(2*pi/(2*N)*(n+1/2)*0);
for l=2:N
    y2(l,:)=sqrt(2)*sin(2*pi/(2*N)*(n+1/2)*(l-1));
end

figure(1)
for l=1:8
    subplot(8,1,l)
    plot(n0,real(y0(l,:)),':'); hold on;
    plot(x3,real(y3(l,:)),'o'); hold on;
    plot(x1,y1(l,:),'*');hold off;
    axis([0,8,-2,2]);
end

figure(2)
for l=1:8
    subplot(8,1,l)
    plot(n0,-imag(y0(l,:)),':'); hold on;
    plot(x3,-imag(y3(l,:)),'o'); hold on;
    plot(x2,y2(l,:),'x'); hold off;
    axis([0,8,-2,2]);
end


hold off;