title: MATLAB:how can I use fprintf or sprintf to print matrix and vectors with strings togheter?
body: <p>I'm at the beginning with the MATLAB software ,and I have two questions:</p>
  
  <p>1) If I want to print a matrix, preceeded by a string, using the     fprintf   command, how can I do?
  For example, to print a matrix alone, I use    </p>
  
  <pre><code>fprintf([repmat('%d\t', 1, size(r, 2)) '\n'], r');   
  </code></pre>
  
  <p>But how can I print a string followed by the matrix, all togheter in fprintf, without usind the disp   function ?
  For example, if I want to print:</p>
  
  <pre><code>&gt;&gt;The matrix you inserted is [1 3; 4 6]
  </code></pre>
  
  <p>2) How can I do the same thing with vectors (I know it's only a particular case of matrix) ?
  I actually use, for example:</p>
  
  <pre><code>&gt;&gt;vectorname=[1 5 2];
  &gt;&gt;strtrim(sprintf('%d  ', vectorname));
  </code></pre>
  
  <p>And it's ok for the only numbers of the vector, but If I insert a string in spintf the result is:</p>
  
  <pre><code> &gt;&gt;vectorname=[1 5 2];
   &gt;&gt;strtrim(sprintf('Your vector is:  %d  ', vectorname))
  
   &gt;&gt;Your vector is 1 Your vector is 5 Your vector is 2
  </code></pre>
  
  <p>How can I inglobe the numbers, one ofter the other, with only one command (sprintf, fprintf, ecc.)??</p>
  
  <p>Thank you very much for the help!</p>