How to print each cell in cell array (of strings) on new row?

36 次查看(过去 30 天)
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!

采纳的回答

Birdman
Birdman 2018-3-26
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by