Next: Character Class Functions, Previous: Searching and Replacing, Up: Strings
Return the decimal number corresponding to the binary number stored in the string s. For example,
hex2dec ("1110") => 14If s is a string matrix, returns a column vector of converted numbers, one per row of s. Invalid rows evaluate to NaN.
See also: dec2hex, base2dec, dec2base, bin2dec, dec2bin.
Return a binary number corresponding the nonnegative decimal number n, as a string of ones and zeros. For example,
dec2bin (14) => "1110"If n is a vector, returns a string matrix, one row per value, padded with leading zeros to the width of the largest value.
The optional second argument, len, specifies the minimum number of digits in the result.
See also: bin2dec, dec2base, base2dec, hex2dec, dec2hex.
Return the hexadecimal string corresponding to the nonnegative integer n. For example,
dec2hex (2748) => "ABC"If n is a vector, returns a string matrix, one row per value, padded with leading zeros to the width of the largest value.
The optional second argument, len, specifies the minimum number of digits in the result.
See also: hex2dec, dec2base, base2dec, bin2dec, dec2bin.
Returns the integer corresponding to the hexadecimal number stored in the string s. For example,
hex2dec ("12B") => 299 hex2dec ("12b") => 299If s is a string matrix, returns a column vector of converted numbers, one per row of s. Invalid rows evaluate to NaN.
See also: dec2hex, base2dec, dec2base, bin2dec, dec2bin.
Return a string of symbols in base b corresponding to the the nonnegative integer n.
dec2base (123, 3) => "11120"If n is a vector, return a string matrix with one row per value, padded with leading zeros to the width of the largest value.
If b is a string then the characters of b are used as the symbols for the digits of n. Space (' ') may not be used as a symbol.
dec2base (123, "aei") => "eeeia"The optional third argument, len, specifies the minimum number of digits in the result.
See also: base2dec, dec2bin, bin2dec, hex2dec, dec2hex.
Convert s from a string of digits of base b into an integer.
base2dec ("11120", 3) => 123If s is a matrix, returns a column vector with one value per row of s. If a row contains invalid symbols then the corresponding value will be NaN. Rows are right-justified before converting so that trailing spaces are ignored.
If b is a string, the characters of b are used as the symbols for the digits of s. Space (' ') may not be used as a symbol.
base2dec ("yyyzx", "xyz") => 123See also: dec2base, dec2bin, bin2dec, hex2dec, dec2hex.
Shift the non-blank text of s to the left, right or center of the string. If s is a string array, justify each string in the array. Null characters are replaced by blanks. If no justification is specified, then all rows are right-justified.
Return ASCII representation of s in a matrix. For example,
toascii ("ASCII") => [ 65, 83, 67, 73, 73 ]
Return a copy of the string s, with each upper-case character replaced by the corresponding lower-case one; nonalphabetic characters are left unchanged. For example,
tolower ("MiXeD cAsE 123") => "mixed case 123"
Return a copy of the string s, with each lower-case character replaced by the corresponding upper-case one; nonalphabetic characters are left unchanged. For example,
toupper ("MiXeD cAsE 123") => "MIXED CASE 123"
Convert special characters in string to their escaped forms.
Converts special characters in strings back to their escaped forms. For example, the expression
bell = "\a";assigns the value of the alert character (control-g, ASCII code 7) to the string variable
bell
. If this string is printed, the system will ring the terminal bell (if it is possible). This is normally the desired outcome. However, sometimes it is useful to be able to print the original representation of the string, with the special characters replaced by their escape sequences. For example,octave:13> undo_string_escapes (bell) ans = \areplaces the unprintable alert character with its printable representation.
If the value of
warn_num_to_str
is nonzero, a warning is printed for implicit conversions of numbers to their ASCII character equivalents when strings are constructed using a mixture of strings and numbers in matrix notation. For example,[ "f", 111, 111 ] => "foo"elicits a warning if
warn_num_to_str
is nonzero. The default value is 1.