N1 = 2;
N2 = 3;
[X, Y] = meshgrid(1:N1, 1:N2);
f = @(u,v) cos((2.*X-1).*(u-1).*pi./2./N1).*cos((2.*Y-1).*(v-1).*pi./2./N2);
close all;
figure(1);
for u=1:N1
    for v=1:N2
        subplot(N1, N2, u+(v-1)*N1);
        axis off;
        set(gca,'xtick',[],'ytick',[]);
        imshow(f(u, v));
    end
end    

figure(2);
for u=1:N1
    for v=1:N2
        subplot(N1, N2, v+(u-1)*N2);
        axis off;
        set(gca,'XTick',[]);
        set(gca,'XTick',[]);
        %fuckmatlab
        surf(X, Y, f(u, v));
    end
end    
