Problem saving to created folders
显示 更早的评论
Hello everyone,
I am having problems exporting files to created folder names. It will successfully create all the folders (inlcuding subfolders) in the various locations but only exports to the first One Drive Folder (see sv_direct). I have looked at the looping, deleted the folder locations, added a timestamp to the folders but the problem still persists. I know there is a looping probelm but I can't see it.
Could someone have a look please?
Thanks
sv_direct =[{'D:\One drive\OneDrive - X University\PhD\TecPlot\MATLAB_sim_var'},{'D:\Geostudio\TecPlot\MATLAB_sim_var'},{'D:\One drive\X University\Coastal - Shared\R R'},{'G:\Matlab_tables'}];
currDate = strrep(datestr(datetime('now')), ':', '_');
coupled_names = see attachment
%Main loop: Goes through slope angle data
for a = 1:5
% creates graphs - keeps them maximised for export
%Nested loop: Creates new folder directories - with slope angle specific subfolders (including timestamp)
for i = 1:size(sv_direct,2)
full_cycle_sav_locs{1,i} = sprintf('%s/Flu_trns_cpd_figures/%s/%s', sv_direct{i},string(coupled_names(a)),currDate);
%create the folder if it doesn't exist already.
if ~exist(full_cycle_sav_locs{i}, 'dir')
mkdir(full_cycle_sav_locs{i});
end
end
%Nested loop: Takes the subfolders above and saves figures to these locations
for k = 1 : size(full_cycle_sav_locs,2)
for j = 1:length(findobj('type','figure'))
figureBaseFile = sprintf('figure_%d.png',j);
FullfigureFile = fullfile(full_cycle_sav_locs{k},figureBaseFile);
%figure(j)
export_fig(FullfigureFile)
fprintf('Saving %s \n' ,full_cycle_sav_locs{k});
close
end
fprintf('Saving to: %s.\n', full_cycle_sav_locs{k});
end
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!