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

16 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Birdman
Birdman il 26 Mar 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)

Più risposte (0)

Categorie

Scopri di più su Workspace Variables and MAT-Files in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by