Use concatenation, substrings and other elementary manipulations of character strings.
Strings for Filenames
1. Define input character strings a and b.
2. Use the concat function, with the current working directory (CWD) variable, to build path names for file reading functions.
This variable name can be passed to the READFILE function, for example, or looped through a program to read sequential files from a directory.
You can also use the format function to concatenate strings combined with variables.
Substrings and Position
1. Use the substr function to extract the string that starts at position 3 and contains four characters.
2. Use the strlen function to calculate the length of string c.
3. Use the search function to locate the starting position of the file extension substring within c.
4. Write a program to find all occurrences of a substring in a character string.
5. Use the program to find all occurrences of "in" in the string below.
Converting Strings to Numbers
1. Use functions rows, cols, IsString, search, concat, substr, strlen and str2num to convert strings to numbers.
Strings and numbers can be mixed in matrices. You can use lookup functions to search for strings as well as numbers.
2. Use the program to convert the strings in matrix M to numbers.
This program uses the str2num to convert strings to numbers. To convert numbers to strings, use num2str.
3. Change the program so that it sends out an error message if the matrix contains elements that are not strings, and use it.
In the second call, the functions returned the error message that was specified as a parameter of the error function.
4. Write a program to create a vector from a character string consisting of a numerical sequence. Each number is separated from the preceding number by a comma and a space.
5. Use the program to convert the following character sequence to a vector.
ASCII Code Conversions
1. Use the str2vec function to convert a string to a vector of ASCII codes.
2. Use the vec2str function to convert a vector of ASCII codes to a string.
3. Use the str2vec and vec2str functions to perform uppercase/lowercase transformations for character strings.
a. Use the str2vec function to define the upper/lower case characters.
b. Use the str2vec andvect2str functions to define the upper/lower case variables.
c. Use the previous definitions to convert character string S to lowercase.
d. Use the previous definitions to convert character string T to uppercase.