plotting within a for loop
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 17 Feb. 2013
Bearbeitet: Azzi Abdelmalek
am 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 Kommentare
Weitere Antworten (1)
Image Analyst
am 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 Kommentare
Walter Roberson
am 21 Feb. 2013
Image Analyst did say you needed to download export_fig, and even gave you the URL.
Siehe auch
Kategorien
Mehr zu Spreadsheets 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!