- ischar true if the input argument is a character vector
- isstring true if the input argument is a string
- isStringScalar true if the input argument is a string scalar
“is” and true/false Functions - functions for strings and character vectors:
- isletter true if the input argument is a letter of the alphabet
- isspace true if the input argument is a white space character
- isstrprop determines whether the characters in a string are in a category specified by second argument, e.g. ‘alphanumeric’
- contains determines whether a substring is somewhere within a string
- endsWith/startsWith determine whether text ends with (or starts with) a specified string
String/Number Functions - Converting from strings to numbers and vice versa:
- int2str converts from an integer to a character vector storing the integer
- num2str converts a real number to a character vector containing the number
- string converts number(s) to strings
- str2num (and str2double) converts from a string or character vector containing number(s) to a number array
- Note: this is different from converting to/from ASCII equivalents
Common Pitfalls - Trying to use == to compare character vectors for equality, instead of the strcmp function (and its variations)
- Confusing sprintf and fprintf. The syntax is the same, but sprintf creates a string whereas fprintf prints
- Trying to create a vector of character vectors with varying lengths (use string arrays instead)
- Forgetting that when using strtok, the second argument returned (the “rest” of the string) contains the delimiter.
Do'stlaringiz bilan baham: |