MATLAB Help Center
Reverse order of characters in strings
newStr = reverse(str)
newStr = reverse(str) reverses the order of the characters in str.
newStr
str
example
collapse all
Reverse the strings in a string array and find strings that read the same when reversed.
str = ["airport","control tower","radar","runway"]
str = 1×4 string "airport" "control tower" "radar" "runway"
newStr = 1×4 string "tropria" "rewot lortnoc" "radar" "yawnur"
tf = (newStr == str)
tf = 1×4 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.
expand all
The reverse function fully supports tall arrays. For more information, see Tall Arrays.
reverse
Usage notes and limitations:
str must be a string scalar, a character vector, or a cell array containing not more than one character vector.
backgroundPool
ThreadPool
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Introduced in R2016b
flip | fliplr | reshape | replace | upper | lower | eq
flip
fliplr
reshape
replace
upper
lower
eq
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office