Reverse order of characters in strings
newStr = reverse(str)
example
newStr = reverse(str) reverses the order of the characters in str.
newStr
str
collapse all
Reverse the strings in a string array and find strings that read the same when reversed. Starting in R2017a, you can create strings using double quotes.
str = ["airport","control tower","radar","runway"]
str = 1x4 string "airport" "control tower" "radar" "runway"
newStr = 1x4 string "tropria" "rewot lortnoc" "radar" "yawnur"
tf = (newStr == str)
tf = 1x4 logical array 0 0 1 0
str(tf)
ans = "radar"
Input text, specified as a string array, character vector, or cell array of character vectors.
Output text, returned as a string array, a character vector, or a cell array of character vectors. str and newStr are the same data type.
This function fully supports tall arrays. For more information, see Tall Arrays.
Usage notes and limitations:
str must be a string scalar, a character vector, or a cell array containing not more than one character vector.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
eq | flip | fliplr | lower | replace | reshape | upper
eq
flip
fliplr
lower
replace
reshape
upper
You have a modified version of this example. Do you want to open this example with your edits?