reverse - Reverse order of characters in strings - MATLAB (original) (raw)

Main Content

Reverse order of characters in strings

Syntax

Description

[newStr](#bu5rtiu-newStr) = reverse([str](#bu5rtiu-str)) reverses the order of the characters in str.

example

Examples

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 = 1×4 logical array

0 0 1 0

Input Arguments

collapse all

Input text, specified as a string array, character vector, or cell array of character vectors.

Output Arguments

collapse all

Output text, returned as a string array, a character vector, or a cell array of character vectors. str andnewStr are the same data type.

Extended Capabilities

expand all

Thereverse function fully supports tall arrays. For more information, see Tall Arrays.

Usage notes and limitations:

Version History

Introduced in R2016b