fout = fopen(binFileName, 'w');
for r = 1:size(data{1, 1}.X, 1)
for c = 1:size(data{1, 1}.X, 2)
fwrite(fout, data{1, 1}.X(r, c), 'float');
end
end
fclose(fout);

回答 (1 件)

Jan
Jan 2018 年 3 月 27 日
編集済み: Jan 2018 年 3 月 27 日

0 投票

fout = fopen(binFileName, 'w');
if fout == -1
error('Cannot open file fro writing: %s', binFileName);
end
fwrite(fout, data{1}.X.', 'float');
fclose(fout);
This could be slightly faster with fopen('W') (upper-case). But even then the hard disk will be the bottleneck.

3 件のコメント

Luigi Bianchi
Luigi Bianchi 2018 年 3 月 28 日
編集済み: Walter Roberson 2018 年 3 月 28 日
Thank you, it works, but the data{1} should be data{1, 1}. So, the final version should be:
fout = fopen(binFileName, 'w');
if fout == -1
error('Cannot open file fro writing: %s', binFileName);
end
fwrite(fout, data{1, 1}.X.', 'float');
fclose(fout);
Walter Roberson
Walter Roberson 2018 年 3 月 28 日
data{1} and data{1,1} are the same location. data{1} is linear indexing form, and is always equivalent to data{1,1}.
Luigi Bianchi
Luigi Bianchi 2018 年 3 月 28 日
Oh, thank you for teaching this too!!!

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

カテゴリ

ヘルプ センター および File Exchange で Get Started with Optimization Toolbox についてさらに検索

製品

タグ

質問済み:

2018 年 3 月 27 日

コメント済み:

2018 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by