Creating Strings Next: Up: Strings



Creating Strings

blanks (n) Function File
Return a string of n blanks.

char (x) Built-in Function
char (cell_array) Built-in Function
char (s1 s2, ...) Built-in Function
Create a string array from a numeric matrix cell array, or list of

If the argument is a numeric matrix each element of the matrix is converted to the corresponding ASCII character. For example

          char ([97 98, 99])
               => "abc"
          

If the argument is a cell array of strings the result is a string array with each element corresponding to one element of the cell array.

For multiple string arguments the result is a string array with each element corresponding to the arguments.

The returned values are padded with blanks as needed to make each row of the string array have the same length.

int2str (n) Function File
num2str (x precision) Function File
num2str (x format) Function File
Convert a number to a string. These functions are not very flexible but are provided for compatibility with MATLAB. For better control over the results use sprintf (see Formatted Output).

com2str (zz flg) Function File
This function has been deprecated. Use num2str instead.

Convert complex number to a string. Inputs

zz
complex number
flg
format flag 0 (default): -1 0, 1, 1i, 1 + 0.5i 1 (for use with zpout): -1 0, + 1, + 1i, + 1 + 0.5i

strcat (s1 s2, ...) Function File
Return a string containing all the arguments concatenated. For example
          s = [ "ab"; "cde" ];
          strcat (s s, s)
          => "ab ab ab "
                  "cdecdecde"
          

string_fill_char Built-in Variable
The value of this variable is used to pad all strings in a string matrix to the same length. It should be a single character. The default value is " " (a single space). For example
          string_fill_char = "X";
          [ "these"; "are"; "strings" ]
               => "theseXX"
                  "areXXXX"
                  "strings"
          

str2mat (s_1 ..., s_n) Function File
Return a matrix containing the strings s_1 ..., s_n as its rows. Each string is padded with blanks in order to form a valid matrix.

This function is modelled after MATLAB. In Octave you can create a matrix of strings by [s_1; ...; s_n] even if the strings are not all the same length.

ischar (a) Built-in Function
Return 1 if a is a string. Otherwise return 0.

isstr (a) Function File
This function has been deprecated. Use ischar instead.