how can n I export file with Excle format, with fprintf
조회 수: 3 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
채택된 답변
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
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);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!