divide text into smaller blocks text by . or enter

if i want to separate content of a text into smaller parts according to "new line" or "."
how to do that?
such as 2 paragraphs , 1*1 matrix:
["Today is a good day. Mom cooks breakfast for us.
But I find out only my sister is served."]
into 2*1 matrix ,divided according to being paragraphed :
["Today is a good day. Mom cooks breakfast for us.";
"But I find out only my sister is served."]
or 3*1 matrix, divided according to being paragraphed and period"." :
["Today is a good day." ;
"Mom cooks breakfast for us.";
"But I find out only my sister is served."]
thanks for helping.

 Accepted Answer

S = "Today is a good day. Mom cooks breakfast for us." + newline + ...
"But I find out only my sister is served."
S =
"Today is a good day. Mom cooks breakfast for us. But I find out only my sister is served."
T = split(S, newline);
T(1)
ans = "Today is a good day. Mom cooks breakfast for us."
T(2)
ans = "But I find out only my sister is served."

2 Comments

thanks for replying.
although it works in your way, the problem is that the text is given. the "newline" command is not what i enter. and there are hundreds of paragraphs.
Sorry. My bad. It does work. Thank you very much.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!