title: How do I get fprintf to preserve space for an empty numerical value?
body: <p>In MATLAB, I'm using <code>fprintf</code> to print a list of numerical values under column headings, like so:</p>
  
  <pre><code>fprintf('%s %s %s %s\n', 'col1', 'col2', 'col3', 'col4')
  for i = 1:length(myVar)
      fprintf('%8.4g %8.4g %8.4g %8.4g\n', myVar{i,1}, myVar{i,2}, myVar{i,3}, myVar{i,4})
  end
  </code></pre>
  
  <p>This results in something like this:</p>
  
  <pre><code>    col1     col2     col3     col4
     123.5    234.6    345.7    456.8
  </code></pre>
  
  <p>However, when one of the cells is empty (e.g. <code>myVar{i,3} == []</code>), space is not preserved:</p>
  
  <pre><code>    col1     col2     col3     col4
     123.5    234.6     456.8
  </code></pre>
  
  <p>How do I preserve space in my format for a numerical value that may be empty?</p>