How to split multilines text line by line in MatLab? - splitlines -- MatLab

 How to split multilines text line by line in MatLab? - splitlines -- MatLab


How to split multilines text line by line in MatLab?
[Ans]
splitlines

[description]
It splits multilines text by keyword newline.

[NOTE]
Great Importance!!! Please pay a lot of attention on it!!!

It does not split it by the character '\n'.
If you wanna split it by  the character '\n',
you can use
replace(s,"\n",newline)
or 
compose(s)
to make a string which contains a real line (newline)

more details on:

code
clear
clc
nl=newline
s='q'
sArr=[s newline]
sArr2=[s nl]
sArr3=s+newline
sArr4=s+"\n"
class(sArr)
newS=splitlines(sArr)
newS2=splitlines(sArr2)
sArr3=string(sArr3)
class(sArr3)
newS3=splitlines(sArr3)
newS4=splitlines(sArr4)

result:

nl =

'
'


s =

'q'


sArr =

'q
'


sArr2 =

'q
'


sArr3 =

123


sArr4 =

"q\n"


ans =

'char'


newS =

2×1 cell array

{'q' }
{0×0 char}


newS2 =

2×1 cell array

{'q' }
{0×0 char}


sArr3 =

"123"


ans =

'string'


newS3 =

"123"


newS4 =

"q\n"

Comments

Popular posts from this blog

How to check a type of specified variable is a specified type in MatLab? - isa -- MatLab