I have created 2 for loop. The first is for 5 subjects. The second one is for 4 measurements. Then I have a code to save a figure for each subject per test. But now it stores each figure in my main folder 'Data_examen'. I want to create a subfolder for each subject, so 'Subject1'…'Subject5'. And each subfolder must contain the 4 figures of their measurements… I have no idea how to do this. But this is my code I already have:
for welke_pp=1:aantal_pp %for 5 subjects
... endfor i_testen=1:length(data_stair_rise)-1 %for 4 measurements
folder = 'Data_examen' %my main folder (where I want to create my subfolders...)
% Create a PNG filename.
pngFileName = sprintf('3Dplot_subject%d_trial%d.png', welke_pp, i_testen); fullFileName = fullfile(folder, pngFileName);saveas(gcf,fullFileName); %save current opened figure
Best Answer