Watch this Author's files
Nice implemetation and sample data to test the file on. However, it runs a bit slow. I recompted the variable Djk by avoiding loops and it runs much faster: Djk = - 2*Y' + diag(Y')*ones(1,n) + ones(n,1)*diag(Y')'; /J.D.
Contact us at files@mathworks.com