projectdir = '.';
foldinfo = dinfo(projectdir);
foldinfo(~[foldinfo.isfolder]) = [];
foldinfo(ismember({foldinfo.name}, {'.', '..'})) = [];
foldnames = fullfile(projectdir, {foldinfo.name});
numfold = length(foldnames);
out = cell(1275,1);
for D = 1 : numfold
thisfold = foldnames{D};
dinfo = dir( fullfile(thisfold, '*.mat'));
filenames = fullfile(thisfold, {dinfo.name});
numfile = length(filenames);
for F = 1 : numfile
thisfile = filenames{F};
file_struct = load(thisfile);
for n = 1:numel(thisfile)
out{(D-1)*25 + F,1} = cat(1,out{D*F},file_struct.(thisfile{n}));
end
end
end
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/659083-how-to-save-different-mat-files-from-different-folders-in-a-cell-array#comment_1155973
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/659083-how-to-save-different-mat-files-from-different-folders-in-a-cell-array#comment_1155973
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/659083-how-to-save-different-mat-files-from-different-folders-in-a-cell-array#comment_1159218
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/659083-how-to-save-different-mat-files-from-different-folders-in-a-cell-array#comment_1159218
Sign in to comment.