title: How do I put variable values into a text string in MATLAB?
body: <p>I'm trying to write a simple function that takes two inputs, <code>x</code> and <code>y</code>, and passes these to three other simple functions that add, multiply, and divide them. The main function should then display the results as a string containing <code>x</code>, <code>y</code>, and the totals.</p>
  
  <p>I think there's something I'm not understanding about output arguments. Anyway, here's my (pitiful) code:</p>
  
  <pre><code>function a=addxy(x,y)
  a=x+y;
  
  function b=mxy(x,y)
  b=x*y;
  
  function c=dxy(x,y)
  c=x/y;
  </code></pre>
  
  <p>The main function is:</p>
  
  <pre><code>function [d e f]=answer(x,y)
  d=addxy(x,y);
  e=mxy(x,y);
  f=dxy(x,y);
  z=[d e f]
  </code></pre>
  
  <p>How do I get the values for <code>x</code>, <code>y</code>, <code>d</code>, <code>e</code>, and <code>f</code> into a string? I tried different matrices and stuff like:</p>
  
  <pre><code>['the sum of' x 'and' y 'is' d]
  </code></pre>
  
  <p>but none of the variables are showing up.</p>
  
  <p>Two additional issues:</p>
  
  <ul>
  <li>Why is the function returning "ans 3" even though I didn't ask for the length of <code>z</code>?</li>
  <li>If anyone could recommend a good book for beginners to MATLAB scripting I'd really appreciate it.</li>
  </ul>