title: Matlab: number of suplots based on a string with dimensions specified
body: <p>I need to decide how many subplots I need and their sizes and all the information is stored in a string.</p>
  
  <p>Let's say there are four subplots and their sizes are:</p>
  
  <p>Top: 1x1
  Next: 2x1
  Next: 2x1
  Bottom: 1x1</p>
  
  <p>Basically the middle two are two combined pairs.  Normally, I would specify the subplots as follows:</p>
  
  <pre><code>subplot(6,1,1)
  subplot(6,1,[2:3])
  subplot(6,1,[4:5])
  subplot(6,1,6)
  </code></pre>
  
  <p>Now, this information is stored in a string as shown below:</p>
  
  <pre><code>'1;[2:3];[4:5];6'
  </code></pre>
  
  <p>So, the question is what is the most efficient way of getting the axes information from such string.</p>
  
  <p>I can, of course, check each character in a string whether it's <code>','</code>,<code>';'</code>,<code>'['</code>,<code>':'</code>, or <code>']'</code>.  This will require for-looping to <code>length(str)</code> and many if statements, paring <code>'['</code>,<code>':'</code>,<code>']'</code>, asking 'is the character numeric?', 'is it colon, then?', etc.  This is very tedious.</p>
  
  <p>I have tens of figures with such subplots and I can only think that there's got to be a better way of doing this.</p>