Create new dynamic Subfolder and dynamic content
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur File Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!