How can i convert multiples lines into 1 text string (big block)

1 visualización (últimos 30 días)
Casper Mantje
Casper Mantje el 22 de Abr. de 2016
Editada: Stephen23 el 22 de Abr. de 2016
so my file is like:
abcdef
abcdef
abcdef
abcdef
and i would like them to be in 1 text string without enters: 'abcdefabcdefabcdefabcdef'

Respuestas (2)

Stephen23
Stephen23 el 22 de Abr. de 2016
Editada: Stephen23 el 22 de Abr. de 2016
To remove all whitespaces within the text:
str = regexprep(fileread('temp.txt'),'\s+','')
Or to only remove newlines and carriage return characters:
str = regexprep(fileread('temp.txt'),'[\n\r]+','')
I tested these on this file:

J. Webster
J. Webster el 22 de Abr. de 2016
file = textread('text.txt', '%s', 'whitespace','');
file will be a cell array containing the string you want.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by