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.

 채택된 답변

Dan Gianotti
Dan Gianotti 2017년 8월 4일

0 개 추천

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

matlabkid602
matlabkid602 2017년 8월 4일
Perfect Dan, thanks a lot. Have a good weekend.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2017년 8월 4일

댓글:

2017년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by