title: correlation in matlab
body: <p>The following script finds the correlation between each pair of data.</p>
  
  <pre><code>clear all
  LName={'Name1','Name2','Name3','Name4','Name5'};
  Data={rand(12,1),rand(12,1),rand(12,1),rand(12,1),rand(12,1)};
  %place in a structure
  d = [LName;Data];
  Data = struct(d{:});
  
  d1 = cell2mat(struct2cell(Data)');
  [R,P] = corrcoef(d1);
  Correlation = [LName(nchoosek(1:length(R),2)) num2cell(nonzeros(tril(R,-1)))]
  </code></pre>
  
  <p>Furthermore, the script also states in 'Correlation' which combination of data was used in generating the correlation value. From this I am attempting to not only find the correlation between a pair of data but also find the correlation between n number of data, so in addition to the script above I'm trying to find the correlation between 3 sets of data, and then four... and so on, then store this in Correlation. How would I acheive this?</p>