title: Matlab ShortEng number format via sprintf() and fprintf()?
body: <p>I like using MATLAB's <code>shortEng</code> notation in the interactive Command Window:</p>
  
  <pre><code>&gt;&gt; a = 123e-12;
  &gt;&gt; disp(a);
  
     1.2300e-10       % Scientific notation. Urgh!
  
  &gt;&gt; format shortEng;
  &gt;&gt; disp(a);
  
     123.0000e-012    % Engineering notation! :-D
  </code></pre>
  
  <p>But I want to use fprintf:</p>
  
  <pre><code>&gt;&gt; format shortEng;
  &gt;&gt; fprintf('%0.3e', a); 
  1.2300e-10          % Scientific. Urgh!
  </code></pre>
  
  <p>How do I print values with fprintf or sprintf with Engineering formatting using the MATLAB <a href="http://uk.mathworks.com/help/matlab/ref/fprintf.html#inputarg_formatSpec" rel="nofollow">Format Operators</a>? </p>
  
  <p>I know I could write my own function to format the values into strings, but I'm looking for something already built into MATLAB.</p>
  
  <p>NOTE: "Engineering" notation differs from "Scientific" in that the exponent is always a multiple of 3.</p>
  
  <pre><code>&gt;&gt; fprintf('%0.3e', a);    % This is Scientific notation.
  1.230000e-10
  </code></pre>