write cell array of strings in text file

65 ビュー (過去 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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by