title: Calculate maximum number of repetitions of a matrix for a given memory limit
body: <p>While using <code>repmat</code>, I get this error:</p>
  
  <pre><code>Error using repmat
  Requested 2192800x2400 (39.2GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a
  long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
  </code></pre>
  
  <p>I would like a function that accepts two inputs: <code>input_array</code> and <code>max_mem</code>, where the first is the array I would like to replicate, and <code>max_mem</code> is a amount of memory in GBs. The function should return <code>N_max</code>, an integer that maximises the number of rows of <code>repmat(input_array, N_max, 1)</code> while constraining it to be within the memory limit specified by <code>max_mem</code>.</p>