Create new dynamic Subfolder and dynamic content

1 回表示 (過去 30 日間)
MrMedTech
MrMedTech 2016 年 4 月 22 日
編集済み: Walter Roberson 2016 年 4 月 22 日
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 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by