For loop to save all the files

2 ビュー (過去 30 日間)
alphabetagamma
alphabetagamma 2022 年 7 月 14 日
回答済み: KSSV 2022 年 7 月 15 日
Hi, I am creating graphs which contain time series values of some variables, and their projections into the future. Specifically, there are 3 cities. Let's call them city = ['A'; 'B'; 'C'], and three variables. Let the vector of variables be vars_list = ['unrate', 'ffr', inflation_rate']
I have computed the graphs that show the how each of the series has evolved in each country upto the present, followed by the impact of a a shock on one variable at a time from vars_list. For example, one graph can be the forecasts of ffr in city A, where there is a shock on unrate in city B.
I have to do this for all cities and all variables in a for loop. My question is how do I save all the graphs that I get in MALTAB to a folder in the computer through a for loop without having to plot each graph separately and save one by one?

回答 (2 件)

KSSV
KSSV 2022 年 7 月 14 日
for i = 1:10
plot(rand(1,10))
figName = ['plot_',num2str(i),'.png'] ; % you can give path, your desired string here
saveas(gcf,figName)
end
  1 件のコメント
alphabetagamma
alphabetagamma 2022 年 7 月 15 日
Thanks a lot. That helped

サインインしてコメントする。


KSSV
KSSV 2022 年 7 月 15 日
Thanks is accepting the answer.. :)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by