split string when an enter appears in matlab

You can split a string in MATLAB when an enter appears using the splitlines function.

Here's an example:

main.m
myStr = 'Hello
World';

% split string when enter appears
splitted = splitlines(myStr)

% output:
% splitted =
% 
%   2×1 cell array
% 
%     {'Hello'}
%     {'World'}
168 chars
14 lines

The splitlines function splits the input string into a cell array of strings at each newline character.

related categories

gistlibby LogSnag