write cell array of strings in text file

45 visualizaciones (últimos 30 días)
sh as
sh as el 15 de Abr. de 2016
Comentada: sh as el 15 de Abr. de 2016
I would like to save my cell array of strings in a *.txt file. A simple way is like the following:
filePh = fopen('features_.txt','w');
[rows,cols]=size(Strings);
for r=1:rows
fprintf(filePh,'%s\n',Strings{r,1};
end
So, each cell that is a string (like a sentence...) in one row. But some strings are not very well defined. for example in one string there might be two whitespace between words, or even a tab. Then this code separates the strings in to different rows.
Does anyone know the solution?
Thank you very much in advance

Respuesta aceptada

Kirby Fears
Kirby Fears el 15 de Abr. de 2016
filePh = fopen('features.txt','w');
fprintf(filePh,'%s\n',Strings{:});
fclose(filePh);
  8 comentarios
sh as
sh as el 15 de Abr. de 2016
Strange! and, thanks a lot for your help.
sh as
sh as el 15 de Abr. de 2016
Well, for me ';' separated the columns

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by