Create new dynamic Subfolder and dynamic content
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey everybody.
During my last project I had to create a new SubFolder within some snapshots I made.
The intention was to create a new Subfolder for every run of the program without using a variable.
Maybe it's not the best solution but it works=)
I hope this might help if you have to do anything similar.
%gives you actual date and time in this format(can be changed see doc)
DateString = datestr(now,'dd_mm_yyyy_HH_MM_SS');
%save the path to your subfolder (here subfolder is Data-dd_mm_yyyy_HH_MM_SS) so you can create a new Subfolder without a variable e.g.
newSubFolder = sprintf('path of your parent folder\\Data-%s', DateString);
if ~exist(newSubFolder, 'dir')
mkdir(newSubFolder);
end
%here I ploted my image in axes(better to use the axes handle than gca here)
F=getframe(gca);
%snaphot is the name of each snapshot I save with a variable number which I increment in a loop. Don't forget the specification .png oder .jpg etc.
snap=sprintf('\\snapshot-%s.png',num);
whole_path=strcat(newSubFolder,snap);
imwrite(F.cdata,whole_path,'png');
cheers
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations 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!