MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Join the last and first names. The join function places a space character between the
strings it joins. After the join, names is a 5-by-1 string array.

names = join(names)

names = 5x1 string array
"Jones, Mary"
"Adams, John"
"Young, Elizabeth"
"Burns, Paul"
"Spencer, Ann"

Sort the elements of names so that they are in alphabetical order.

names = sort(names)

names = 5x1 string array
"Adams, John"
"Burns, Paul"
"Jones, Mary"
"Spencer, Ann"
"Young, Elizabeth"

See Also
ismissing | isspace | join | plus | sort | split | string | strings | strlength

Related Examples



  • “Analyze Text Data with String Arrays” on page 6-24

  • “Search and Replace Text” on page 6-54

  • “Compare Text” on page 6-47

  • “Test for Empty Strings and Missing Values” on page 6-31

  • “Frequently Asked Questions About String Arrays” on page 6-66


6 Characters and Strings

Free download pdf