Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As <a href="https://stackoverflow.com/questions/2204579/getting-variable-values-into-a-text-string-matlab/2204594#2204594">Peter</a> and <a href="https://stackoverflow.com/questions/2204579/getting-variable-values-into-a-text-string-matlab/2204631#2204631">Amro</a> illustrate, you have to convert numeric values to formatted strings first in order to display them or concatenate them with other character strings. You can do this using the functions <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fprintf.html" rel="nofollow noreferrer">FPRINTF</a>, <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/sprintf.html" rel="nofollow noreferrer">SPRINTF</a>, <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/num2str.html" rel="nofollow noreferrer">NUM2STR</a>, and <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/int2str.html" rel="nofollow noreferrer">INT2STR</a>.</p> <hr> <p>With respect to getting <code>ans = 3</code> as an output, it is probably because you are not assigning the output from <code>answer</code> to a variable. If you want to get all of the output values, you will have to call <code>answer</code> in the following way:</p> <pre><code>[out1,out2,out3] = answer(1,2); </code></pre> <p>This will place the value <code>d</code> in <code>out1</code>, the value <code>e</code> in <code>out2</code>, and the value <code>f</code> in <code>out3</code>. When you do the following:</p> <pre><code>answer(1,2) </code></pre> <p>MATLAB will automatically assign the first output <code>d</code> (which has the value 3 in this case) to the default workspace variable <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ans.html" rel="nofollow noreferrer"><code>ans</code></a>.</p> <hr> <p>With respect to suggesting a good resource for learning MATLAB, you shouldn't underestimate the value of the MATLAB documentation. I've learned most of what I know on my own using it. You can access it <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/bqr_2pl.html" rel="nofollow noreferrer">online</a>, or within your copy of MATLAB using the functions <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/doc.html" rel="nofollow noreferrer">DOC</a>, <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/help.html" rel="nofollow noreferrer">HELP</a>, or <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/helpwin.html" rel="nofollow noreferrer">HELPWIN</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload