L = 1;
f = 100; % determines the fineness of the grid
n = 50;

[x y] = meshgrid(0:L/f:L, 0:L/f:L);

z = 0;
for k = 1:n
    z = sin(k*pi/L*x).*sin(k*pi/L*y) + z;
end

surf(x,y,z);