What is the fastest way to export a large matrix of numbers from MATLAB to Excel (preferably as .xlsx) ?
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
What is the fastest way to export a large matrix of numbers from MATLAB to Excel (preferably as .xlsx) ?
It looks like there are several ways, such as writematrix, writecell, writetable, xlswrite, csvwrite (apparently, xlswrite and csvwrite are not recommended), etc, but which one is the fastest one for large matrices ?
% Example of matrix of numbers to be exported from Matlab to Excel (preferably as .xlsx):
M = magic(10^3);
0 commentaires
Réponse acceptée
Jan
le 19 Nov 2022
Modifié(e) : Jan
le 19 Nov 2022
Simply try it:
M = magic(10^3);
tic;
writematrix(M, 'file1.xlsx');
toc
tic;
writecell(num2cell(M), 'file2.xlsx');
toc
tic;
writetable(table(M), 'file3.xlsx');
toc
tic;
xlswrite('file4.xlsx', M);
toc
tic;
csvwrite('file5.csv', M);
toc
tic;
fid = fopen('file6.csv', 'W');
fmt = [repmat('%g, ', 1, 999), '%g\n'];
fprintf(fid, fmt, M.');
fclose(fid);
toc
tic;
fid = fopen('file7.csv', 'W');
fmt = [repmat('%g, ', 1, 999), '%g\n'];
fwrite(fid, sprintf(fmt, M.'), 'char');
fclose(fid);
toc
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!