Format string length in Matlab
<p>I am outputting multiple lines of 4 columns of data to a file, the first column is the name of the variable, and the next 3 columns are data at 3 points in time. I would like the data to be formatted such that the 1st column of strings are all the same length, (ie. each variable name to have trailing whitespace so it takes the same length)</p>

<p>What I'm getting to output is this</p>

<pre><code>Pressure  1  2  3 
Temperature  1  2  3
Speed  1  2  3
</code></pre>

<p>What I would like is this:</p>

<pre><code>Pressure     1  2  3 
Temperature  1  2  3
Speed        1  2  3
</code></pre>

<p>I am currently ouputting to file like so:</p>

<pre><code>fprintf(fid,'%s/t%d/t%d/t%d',data{:})
</code></pre>