필터 지우기
필터 지우기

write cell array of strings in text file

조회 수: 80 (최근 30일)
sh as
sh as 2016년 4월 15일
댓글: sh as 2016년 4월 15일
I would like to save my cell array of strings in a *.txt file. A simple way is like the following:
filePh = fopen('features_.txt','w');
[rows,cols]=size(Strings);
for r=1:rows
fprintf(filePh,'%s\n',Strings{r,1};
end
So, each cell that is a string (like a sentence...) in one row. But some strings are not very well defined. for example in one string there might be two whitespace between words, or even a tab. Then this code separates the strings in to different rows.
Does anyone know the solution?
Thank you very much in advance

채택된 답변

Kirby Fears
Kirby Fears 2016년 4월 15일
filePh = fopen('features.txt','w');
fprintf(filePh,'%s\n',Strings{:});
fclose(filePh);
  댓글 수: 8
sh as
sh as 2016년 4월 15일
Strange! and, thanks a lot for your help.
sh as
sh as 2016년 4월 15일
Well, for me ';' separated the columns

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

추가 답변 (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