saving files in a loop with different names

5 vues (au cours des 30 derniers jours)
h k
h k le 15 Juin 2021
Commenté : Stephen23 le 15 Juin 2021
hello
in my code created one file is name (info.dat)
I have save every file has created.
File content attached
for k = 1:20
...
% here created (info.dat)
...
end
  3 commentaires
h k
h k le 15 Juin 2021
it does not matter
The name of the (info.dat) plus one to 20
example (info1.dat, info2.dat, ...)

Connectez-vous pour commenter.

Réponse acceptée

Scott MacKenzie
Scott MacKenzie le 15 Juin 2021
for k=1:20
...
filename = sprintf('info%d.dat', k);
writematrix(M, filename); % data in M
...
end

Plus de réponses (0)

Catégories

En savoir plus sur Entering Commands 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