title: Fast Calculation of Pairwise Cosine Directional Distance Between Points in a (n x d x t) matrix
body: <p>I am aware of the pdist(X,distance) in Matlab to take an (nxd) matrix of points and calculate the pairwise distances between them. I am also aware that it has an extra option to calculate the cosine distance if a matrix contain vectors rather than points.</p>
  
  <p>What I would like to do is take a (n x d x t) matrix, which holds the varying positions of samples over time t and efficiently / quickly calculate the cosine directional distance between all pairs / all frames, where a v(t) is defined as the direction as calculate by p(t+1) - p(t), and p(t) refers to the row M(p,:,t).</p>
  
  <p>Obviously I don't want to be using loops if can be helped. Any suggestions?</p>
  
  <p>Any help much appreciated.</p>