How can you find the ascii value of a character?

This question arose after noticing that num2str(x) returns the ascii character corresponding to the number x. The question is how to go the other way. We know, for example, that ['0' 66] results in the string 0B, thereby mapping the number 66 to the character B but a more straightforward solution is to use char(66) which returns B. For fun you can try the following:
   >> x=32:1:126;
   >> char(x)
The result is
which shows all the printable ascii characters in order.

What is important about this question is the procedure used to find the answer. What I did was the following:

  1. Realized that what we were looking for is something that appears to be the inverse of num2str.
  2. Guessed the inverse might be str2num.
  3. Did help str2num.
  4. This was not exactly what is called for because it only works on ascii characters that represent numbers.
  5. At the bottom of the help page there is a see also section.
  6. The function char was listed there.
  7. Did help char.
  8. Determined that is what is wanted.
The above procedure illustrates how you will learn more about MATLAB as you use the tool. You will be coding and determine a need for a function. Then you will need to check MATLAB for the existence of that function. Doing so efficiently is, obviously, important.