saving files in a loop with different names

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 Kommentare

Geoff Hayes
Geoff Hayes am 15 Jun. 2021
hesam - how should each file be named? What is the naming convention that you wish to adopt for your files?
h k
h k am 15 Jun. 2021
it does not matter
The name of the (info.dat) plus one to 20
example (info1.dat, info2.dat, ...)

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Scott MacKenzie
Scott MacKenzie am 15 Jun. 2021

1 Stimme

for k=1:20
...
filename = sprintf('info%d.dat', k);
writematrix(M, filename); % data in M
...
end

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange

Gefragt:

h k
am 15 Jun. 2021

Kommentiert:

am 15 Jun. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by