concat of 3d mat files in a folder
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
khaled alsaih
el 5 de Jun. de 2018
Comentada: khaled alsaih
el 6 de Jun. de 2018
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
5 comentarios
Jan
el 5 de Jun. de 2018
If you want to use a loop, how are the wanted files recognized? We cannot guess, which 20 files you want. But a meaningful example code must contain a method to determine the files. So please reveal the details.
Respuesta aceptada
Jan
el 5 de Jun. de 2018
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');
3 comentarios
Más respuestas (1)
KSSV
el 5 de Jun. de 2018
A = rand(512,1024,128) ;
B = rand(668,512,64) ;
C = rand(512,512,49) ;
Ai = imresize(A,[512,512]) ;
Bi = imresize(B,[512,512]) ;
Ci = imresize(C,[512,512]) ;
iwant = cat(3,Ai,Bi,Ci) ;
2 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!