how can n I export file with Excle format, with fprintf

9 ビュー (過去 30 日間)
zina shadidi
zina shadidi 2020 年 11 月 9 日
コメント済み: zina shadidi 2020 年 11 月 9 日
how can I export file with Excle format, with fprintf
i have the flowing lines :
fid:fopen ('elements. txt', 'w')
fprintf (fid, %15.10f %15.10f %15.10f/n',elements)
these lines make a text file wich is not readable by another code)

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 11 月 9 日
fprintf can only write data to text file. It cannot write data to Excel file. TO write data in Excel format use the function writematrix
% Creating a random data, replace this with your data
elements = rand(100, 4);
% Write to .txt file
fid = fopen ('elements.txt', 'w');
fprintf (fid, '%15.10f %15.10f %15.10f\n', elements);
% Write to .xlsx file
writematrix(elements, 'elements.xlsx');
  3 件のコメント
Subhadeep Koley
Subhadeep Koley 2020 年 11 月 9 日
編集済み: Subhadeep Koley 2020 年 11 月 9 日
zina shadidi you can achieve the same result with the function writetable too. writetable is available in MATLAB r2018.
% Creating a random data, replace this with your data
elements = rand(100, 4);
% Write to .txt file
fid = fopen ('elements.txt', 'w');
fprintf (fid, '%15.10f %15.10f %15.10f\n', elements);
% Write to .xlsx file
writetable(array2table(elements), 'elements.xlsx',...
'WriteVariableNames', false);
zina shadidi
zina shadidi 2020 年 11 月 9 日
Thanks a lot subhadeep koley , it works , but let me ask you please how can l arrange the elements in Exle file as in text file in two coloumn .

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by