title: MATLAB: Splitting a matrix into vectors
body: <p>I'm new here and my first question, so please bear with me...</p>
  
  <p>I collect motion analysis data, the raw data format is in a matrix of n columns. Each column can have a different number of rows.</p>
  
  <p>I need to normalise this matrix so that each column has 101 data points. So far all of the raw data has had 21 columns, so I wrote the following function to normalise:</p>
  
  <pre><code> function output = process(Test_Data)
  % first step is to split the imported matrix into its component vectors:
  C1 = Test_Data(:,1);
  C2 = Test_Data(:,2);
  C3 = Test_Data(:,3);
  C4 = Test_Data(:,4);
  C5 = Test_Data(:,5);
  C6 = Test_Data(:,6);
  c7 = Test_Data(:,7);
  c8 = Test_Data(:,8);
  c9 = Test_Data(:,9);
  c10 = Test_Data(:,10);
  c11 = Test_Data(:,11);
  c12 = Test_Data(:,12);
  c13 = Test_Data(:,13);
  c14 = Test_Data(:,14);
  c15 = Test_Data(:,15);
  c16 = Test_Data(:,16);
  c17 = Test_Data(:,17);
  c18 = Test_Data(:,18);
  c19 = Test_Data(:,19);
  c20 = Test_Data(:,20);
  c21 = Test_Data(:,21);
  
  %Second step is to normalise each of the raw data variables
  
  c1 = normalisation(C1);
  c2 = normalisation(C2);
  c3 = normalisation(C3);
  c4 = normalisation(C4);
  c5 = normalisation(C5);
  c6 = normalisation(C6);
  c7 = normalisation(c7);
  c8 = normalisation(c8);
  c9 = normalisation(c9);
  c10 = normalisation(c10);
  c11 = normalisation(c11);
  c12 = normalisation(c12);
  c13 = normalisation(c13);
  c14 = normalisation(c14);
  c15 = normalisation(c15);
  c16 = normalisation(c16);
  c17 = normalisation(c17);
  c18 = normalisation(c18);
  c19 = normalisation(c19);
  c20 = normalisation(c20);
  c21 = normalisation(c21);
  
  %Then combine the normalised vectors into a matrix
  
  Processed_Data = [c1; c2; c3; c4; c5; c6; c7; c8; c9; c10; c11; c12; c13; c14; c15; c16; c17; c18; c19; c20; c21];
  Processed_Data = Processed_Data';
  
  %Output the final result
  
  output = Processed_Data;
  </code></pre>
  
  <p>(where 'normalisation' is another function I wrote to normalise a vector to 101 data points)</p>
  
  <p>I have a problem where now I'm processing matrices that have different numbers of columns, sometimes just a few, occasionally up to 100. I'd like to use a for loop but am struggling to work out how to store each of the vectors. </p>
  
  <p>So far I've got to:</p>
  
  <pre><code>NumberofColumns = size(data)
  NumberofColumns = NumberofColumns(1,2)
      for i = 1 : NumberofColumns   
      Vector = data(:, i);       
  end
  </code></pre>
  
  <p>But of course that just outputs the last column of the matrix as a variable. Is there a way of storing each of the vectors that are output.</p>
  
  <p>Any help is much appreciated! As I said, I'm new to MatLab so apologies if the coding/language is a little strange.</p>