%% Split String at Newline
% Split a string at a newline character. When the literal \n represents a newline character, convert it to an actual newline using the compose function. Then use splitlines to split the string at the newline character.
% Create a string in which two lines of text are separated by \n. You can use + to concatenate text onto the end of a string. Starting in R2017a, you can create strings using double quotes.

str = "In Xanadu did Kubla Khan";
str = str + "\n" + "A stately pleasure-dome decree"

%
% Convert \n into an actual newline character. Although str displays on two lines, str is a 1-by-1 string containing both lines of text.

str = compose(str)

%
% Split str at the newline character. newStr is a 1-by-2 string array. Each element contains one line of the text.

newStr = splitlines(str)

% Copyright 2012 The MathWorks, Inc.