write cell output to a joint txt file

3 ビュー (過去 30 日間)
sensation
sensation 2018 年 7 月 12 日
コメント済み: Guillaume 2018 年 7 月 12 日
Hi, I have an output and want to write all cells into the same file so that each cell that is of different size will be next to each other in the final file. I am trying to use fprintf.
% Result is 1x13 cell where each cell is different size of double type
% Result(1)=[139x2 double]
% Result(2)=[54x2 double] etc;
Res=cell2table(Result);
max_num_col = 26;
fileID = fopen('Result.txt','w');
format = repmat('%f',1,max_num_col);
fprintf(fileID,format,Res);
fclose(fileID);
Thanks!
  4 件のコメント
OCDER
OCDER 2018 年 7 月 12 日
編集済み: OCDER 2018 年 7 月 12 日
Is this the final output you want, something like this?
Res{1} Res{2} Res{3}
1 3 1 2 1 4
2 1 3 4 2 2
3 3 5 6 5 3
4 7 7 4
8 5
sensation
sensation 2018 年 7 月 12 日
Yes in the same matrix, so first two columns are Res{1}, second two Res{2} and so on. Thanks!

サインインしてコメントする。

回答 (1 件)

Guillaume
Guillaume 2018 年 7 月 12 日
Well, assuming that the conversion to table has been successful, simply:
writetable(Res, 'Result.txt');
should do it. If not, giving us an actual example of the data would help.
  2 件のコメント
sensation
sensation 2018 年 7 月 12 日
Here is the file Guillaume. Thanks!
Guillaume
Guillaume 2018 年 7 月 12 日
No file was attached.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by