N=100 lowX=-3 highX=3 for i=1:N for j=1:N x(i,j)=lowX+i*(highX-lowX)/N; y(i,j)=lowX+j*(highX-lowX)/N; z(i,j)=cos(x(i,j).^2+y(i,j).^2); end end