MATLAB: Concat of 3d mat files in a folder

image processingImage Processing Toolboxlinux

i have 20 3d mat files in a folder and i have different sizes for each ex: 512*1024*128 668*512*64 512*512*49 etc all i need is to load these data then resize the first two dimensions to 512*512 and to make one mat file for all can anyone help me please

Best Answer

With a loop:
Folder = 'C:\Your\Path'; % Adjust the path to your needs
List = dir(fullfile(Folder, '*.mat'));
C = cell(size(List));
for k = 1:numel(List)
Data = load(fullfile(Folder, List(k).name));
M = Data.??? % Unfortunately you do not reveal what in the MAT files is.
% Perhaps:
% M = Data.Value;
C{k} = imresize(M, [512, 512]); % See KSSV's answer
end
Result = cat(3, C{:});
save('Output.mat', 'Result');