Filter löschen
Filter löschen

Saving Table In For Loop?

2 Ansichten (letzte 30 Tage)
matlabkid602
matlabkid602 am 4 Aug. 2017
Kommentiert: matlabkid602 am 4 Aug. 2017
How can I save a table in a for loop with corresponding file name?
I want to save it like how I am saving my figures, savefig(['gridded_dipoles_' num2str(i)]);
where i is my index.
How can I do this with writetable?
Thank you.

Akzeptierte Antwort

Dan Gianotti
Dan Gianotti am 4 Aug. 2017
Something like this?
for i = 1:N
T = calculate_my_table(i); % Whatever you do to get your table
fname = ['MyTable',num2str(i),'.csv']; % or .txt, or however you want to save it
writetable(T,fname);
end
The sprintf function might help you think about how to make varying filenames as well.
  1 Kommentar
matlabkid602
matlabkid602 am 4 Aug. 2017
Perfect Dan, thanks a lot. Have a good weekend.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by