Compare Multiple Time Series in Matlab I have a multi-variate time series which represent the heading (-2*PI - +2*PI) of a set of virtual agents over time. 
What I would like to have is some form of correlation function which describes the relationship among the variation of heading of agents over time, so that given another multi-variate time series of another set of agents, I can state whether their motion pattern was similar to the 1st set or not.
I'm working with Matlab and read about cross-correlation, cross-variance, but with my limited knowledge in statistics I'm still unable to determine how I could come up with somekind of a function which maps to the given graph. I would appreciate any guidance to direct me in the correct path. 
Edit: Both sets of agents that I talk about here are equal in number, and all environmental conditions are the same, except that the two sets have two different motion patterns.
 A: Suppose you have $N$ agents. You can estimate the covariance between the headings of each pair of agents to get an $N \times N$ covariance matrix $\Sigma$. This matrix essentially captures the joint structure in the pattern of headings of the different agents. This can be computed using the 'cov' function in Matlab. If you can track the identity of the agents across datasets, you can order the agents in the same way before computing the covariance and then directly compare the covariance matrices of the two datasets to see if there is a high degree of overlap. 
However, since you say that you cannot track the identity of the agents across datasets, you cannot directly compare the covariances. Instead, you could perform an eigen decomposition of $\Sigma$ to get the set of eigenvalues $\it{\lambda_1, ... \lambda_N}$ and eigenvectors $V_1, ... V_N$ of your covariance matrix. Each eigenvector corresponds to a particular pattern of co-fluctuation (a particular mode) in the movements of the different agents and the magnitude of the corresponding eigenvalue tells you how dominant that mode is (the energy of that mode). You can perform eigen decomposition using the Matlab 'eig' function.
Now to establish correspondence between the pattern of movements in the two datasets, you need to do two things:
1) Compare the eigenspectra of the two covariance matrices. You can do this simply by sorting the vector of eigenvalues of each dataset and comparing them (e.g. by computing the dot product). Having similar eigen spectra is necessary but not sufficient to prove that the motion pattern was similar because many different patterns can have similar eigenspectra.
2) If the eigenvalues are similar enough, you can start comparing the dominant modes - the eigenvectors with the most power. Start with the leading eigenvector (the one with the largest eigenvalue). See if they are similar. Again, since your agents may be arranged in any order they most likely won't look similar but rather like shuffled version of each other. In order to compare them you must first sort the elements of the eigenvectors. If they look similar enough, compare the next mode. In practice, it is sufficient to compare the first few leading modes as most of the power is concentrated there.
This is just a rough guideline but I hope this gives you a starting point.
