% dct_separable.m
% dct2 is a separable transform

A = magic(2)

% dct on the rows
R1 = A(1,:)
R2 = A(2, :)
R1_dct = dct(R1)
R2_dct = dct(R2)
R_dct = [R1_dct; R2_dct]

% dct on the columns
C1 = R_dct(:,1)
C1_dct = dct(C1)
C2 = R_dct(:,2)
C2_dct = dct(C2)
C_dct = [C1_dct, C2_dct]

% Compare with dct2 directly applied
dct2(A)
ans =
    5.0000         0
   -1.0000   -2.0000