writing cellArray to txt file.
1 回表示 (過去 30 日間)
古いコメントを表示
%for example;
cellArray=
'p1' [400] [500] [600]
'p2' [650.45] [400.78] [390.90]
[ 3] [400.02] [500.05] [600.120]
%I need to write this cellArray into .txt file as it seems above (3x3). This dimensions would change due to the computations therefore I need to perform loop for writing into txt. Which codes I need to perform orderly place columns and rows of this cellArray into txt file?
0 件のコメント
採用された回答
Azzi Abdelmalek
2014 年 3 月 8 日
cellArray={'p1' [400] [500] [600]
'p2' [650.45] [400.78] [390.90]
[ 3] [400.02] [500.05] [600.120]}
c=cellfun(@num2str,cellArray,'un',0)
[n,m]=size(c)
filename = 'file.txt';
form=[repmat('%s ',1,m) ' \r\n']
fid = fopen(filename, 'w');
for k=1:n
fprintf(fid, form, c{k,:});
end
fclose(fid);
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!