Different cells with different array sizes and outputting them to textfile
1 回表示 (過去 30 日間)
古いコメントを表示
Barry Mooifeld
2015 年 11 月 25 日
編集済み: Walter Roberson
2015 年 11 月 26 日
I have multiple cells (10+) containing arrays of different sizes and I would like to export them as seperate rows in a .dat file (seperated by a space). What is the most easy way to do this?
Cells are ordered like:
Columns 1 through 2
[5x1 double] [5x1 double]
Columns 3 through 4
[9x1 double] [6x1 double]
Columns 5 through 6
[4x1 double] [5x1 double]
I have tried it with dlmwrite, fopen fprint fclose, etc. but none will give me what I want, which is just the vectors pasted into a .dat file seperated by a space.
So
Cell1vector1 Cell1vector2...etc... Cell2vector1 Cell2vector2... etc...
0 件のコメント
採用された回答
Mohammad Abouali
2015 年 11 月 26 日
編集済み: Mohammad Abouali
2015 年 11 月 26 日
assuming that cellArray is the variable storing your different cells; then:
fid=fopen('outputfilename.txt','w');
if (fid==-1)
error('could not open outputfilename.txt for writing.');
end
for idx=1:numel(cellArray)
fprintf(fid,'%f ',cellArray{idx}); % pay attention to space after %f
fprintf(fid,'\n');
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!