distanceMatrix <-
function(N,P){
d_hor = (matrix(rep(cumsum(matrix(1,2*N+1,1)),2*P+1),nrow=2*N+1) - N - 1) ^ 2
d_ver = (matrix(rep(cumsum(matrix(1,2*P+1,1)),2*N+1),ncol=2*P+1,byrow=TRUE) - P - 1) ^ 2
w = sqrt(d_hor + d_ver )
return(w)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.