function saveFigs(folder, figureVar, channelName, path, file) %Suppress the warnings. If not where would be a lot of warnings %because of the creation of folders that already exist warning('off','all'); %Create file folder file = strcat(path, '\', file, 'plots'); mkdir(file); %Create type folder (graph, mean, fourier) folder = strcat(file, '\', folder); mkdir(folder); %Create path for saving and save as .fig and .png pathName = strcat(folder, '\', channelName); savefig(figureVar, strcat(pathName, '.fig')); saveas(figureVar, strcat(pathName, '.png')); %Turn warning back on warning('on','all') end