Filter löschen
Filter löschen

Writing contents cell into a txt file

1 Ansicht (letzte 30 Tage)
T Shep
T Shep am 5 Okt. 2016
Kommentiert: T Shep am 5 Okt. 2016
I have 3 words in one cell (e.g. fox, cat, dog). How would I write all of the contents of that cell to a text file so that all 3 words are on one line and there is a space between each word? I have a loop where I am generating multiple 3 letter word combinations from a word list and then writing them into one text file (appending the file). The text file should look like this:
fox dog cat boy man jet try set buy etc...

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 5 Okt. 2016
c={'dog','cat','fox'};
fid=fopen('out.txt','w+t');
for k=1:10
fprintf(fid,'%s ',c{:});
end
fclose(fid);

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by