Can I use 'for' loop to save multiple plots?
1 view (last 30 days)
Show older comments
Sumanth Kumar
on 2 Mar 2015
Commented: RAVI LAKSHMANAN
on 6 Feb 2020
I would like to create a 3D animation from a set of plots. The data set has 1000 points and I would like to plot 100 points in each figure and then automatically save it from 'saveas' command. Then I can just make a GIF by joining them. But how do I write the program to save the figures as fig1, fig2, fig3... by giving the number as a variable?
0 Comments
Accepted Answer
Guillaume
on 2 Mar 2015
for plotnumber = 1:10
%code for plotting
%hplot = ....
saveas(hplot, fullfile(folder, sprintf('fig%02d.gif', plotnumber)));
end
3 Comments
Guillaume
on 2 Mar 2015
I'm not sure what you're asking. The code you've posted does what you want already (except first plot is named 'fig01.jpg' which makes more sense).
RAVI LAKSHMANAN
on 6 Feb 2020
Hi Guillaume, if the number of plots is unknown, how'd the for loop change? like here you have mentioned for 10p plots?
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!