How to print each cell in cell array (of strings) on new row?
30 次查看(过去 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!
0 个评论
采纳的回答
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)
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!