Saving Multiple .dat files

1 vue (au cours des 30 derniers jours)
Leostar90
Leostar90 le 4 Nov 2022
Commenté : Leostar90 le 7 Nov 2022
I have a matrix with size of 2000*1000. I want to save it into multiple .dat files in such way that each .dat file should have 2000*1 (One vector). So in this way I will have 1000 dat files. I tried many ways but no success yet. Any idea?

Réponse acceptée

Davide Masiello
Davide Masiello le 4 Nov 2022
This should work
A = rand(2000,1000);
for col = 1:size(A,2)
filename = ['Column_',num2str(col),'.dat'];
writematrix(A(:,col),filename)
end
  1 commentaire
Leostar90
Leostar90 le 7 Nov 2022
Thanks. It worked perfectly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB 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!

Translated by