How to print each cell in cell array (of strings) on new row?
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Benjamin Schuessler
el 26 de Mzo. de 2018
Comentada: Jan
el 26 de Mzo. de 2018
Hey all,
I'm having trouble trying to print a cell array, where each cell is on a new line.
For example, lets say we have:
str = {"a" "b" "c"}
and then print the output, where each cell is on a new line. I then wish to write this output to a text file. I just need a little push in the right direction.
Thank you!
0 comentarios
Respuesta aceptada
Birdman
el 26 de Mzo. de 2018
print the output, where each cell is on a new line
>> str{:}
ans =
"a"
ans =
"b"
ans =
"c"
write this output to a text file
str = {"a" "b" "c"}
fileID = fopen('str.txt','w');
fprintf(fileID,'%s\n%s\n%s',str{:});
fclose(fileID)
2 comentarios
Más respuestas (0)
Ver también
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!