-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuperSave.m
More file actions
28 lines (23 loc) · 729 Bytes
/
superSave.m
File metadata and controls
28 lines (23 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function superSave(path, vars)
%SUPERSAVE Saves variables to multiple MAT-files and can create folders
% SUPERSAVE(path, vars) saves the fields in 'vars' to one or more
% MAT-files indicated by 'path', which can be a single string or a
% cell array with multiple paths. If the folders in the paths do not
% exist, superSave will attempt to create them before saving.
%
% Part of Burgbox
% 2013-02 CB created
function saveIndiv(fn)
pathstr = fileparts(fn);
% if the containing folder does not exist, create it
if ~isempty(pathstr) && ~exist(pathstr, 'dir')
mkdir(pathstr);
end
save(fn, '-struct', 'vars');
end
if iscell(path)
cellfun(@saveIndiv, path);
else
saveIndiv(path);
end
end