title: Put elements of a 1D vector into a 3D matrix using another matrix of positions
body: <p>I have a vector of data points which were saved from a 3D array by some other program in one big list. The vector is nk elements long. nk = nx*ny*nz where nx, ny and nz are the dimensions of the original 3D array.</p>
  
  <p>The position of a data point in the original array is stored in a (nk x 3) array, arranged with each row (position(k,:)) giving the (i,j,k) position of the corresponding data point. </p>
  
  <p>I can't use reshape on my data array as the position vector is not simple (it depends on some stuff to do with how the data was generated - it isn't completely random - but I won't necessarily know what it looks like beforehand).</p>
  
  <p>If the nk vector is called 'data', the nk x 3 position array is called 'position' and the output array is called 'data_reshaped' then currently I am doing the following:</p>
  
  <pre><code>for k = 1:nk
      data_reshaped(position(k,1),position(k,2),position(k,3)) = data(k);
  end
  </code></pre>
  
  <p>This is really slow - is there some faster method without knowing much about what 'position' looks like?</p>