plotting within a for loop
2 views (last 30 days)
Show older comments
I have a for loop that takes 2 matrix 365x24 and plots each corresponding matrix line ,i.e. X(3,1:24) and Y(3,1:24), and plots it. I would like to be able to have a figure for every iteration so i can come back to it a look for it. In the long run i should have 365 accessible figures in the workspace. And if i can then take these 365 figures and store then in a folder
0 Comments
Accepted Answer
Azzi Abdelmalek
on 17 Feb 2013
Edited: Azzi Abdelmalek
on 20 Feb 2013
for k=1:365
h=plot(X(k,:),Y(k,:))
hgsave(h,'sprintf('fig%d',k))
close
end
To load your plots use
hgload('figurename')
5 Comments
More Answers (1)
Image Analyst
on 17 Feb 2013
You might want to save them as PNG files so that you can see them in the operating system as thumbnails, that is, if you don't need to interact with them via the figure toolbar anymore.
yourFolder = pwd; % Or whatever folder you want to store them in.
for k=1:365
cla;
plot(X(k,:),Y(k,:));
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
baseFileName = sprintf('Figure #%d.png', k);
fullFileName = fullfile(yourFolder, baseFileName);
export_fig(fullFileName);
end
3 Comments
Walter Roberson
on 21 Feb 2013
Image Analyst did say you needed to download export_fig, and even gave you the URL.
See Also
Categories
Find more on Annotations 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!