The function for this in matlab is called pdist. Unfortunately, this is very slow and does not take into account the ability of vectorization of Matlabs.
Below is the code I wrote for the project. Let me know what speed you get.
Qx=repmat(dot(x,x,2),1,size(x,1));
D=sqrt(Qx+Qx'-2*x*x');
, , . , , , 256 100000 , mac x = rand (256,100000), 256x256 .