%three different ways of filling a matrix whose i,jth entry is
%K(i,j)=f(x(i)-x(j))

N=6000;
x=[0:1/N:1];
f=@(y) log(abs(y));

K=zeros(N+1, N+1);
tic
for i=1:N+1
    K(:,i)=f(x-x(i));
end
t1=toc

tic
for i=1:N+1
    for j=1:N+1
        K(i,j)=f(x(i)-x(j));
    end
end
t2=toc

tic
[xx, yy]=meshgrid(x);
K=f(xx-yy);
t3=toc