필터 지우기
필터 지우기

Writing contents cell into a txt file

조회 수: 1 (최근 30일)
T Shep
T Shep 2016년 10월 5일
댓글: T Shep 2016년 10월 5일
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...

채택된 답변

Fangjun Jiang
Fangjun Jiang 2016년 10월 5일
c={'dog','cat','fox'};
fid=fopen('out.txt','w+t');
for k=1:10
fprintf(fid,'%s ',c{:});
end
fclose(fid);
  댓글 수: 1
T Shep
T Shep 2016년 10월 5일
Thank you! Works perfectly.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by