how do I concatenate mat files matlab

2 visualizaciones (últimos 30 días)
Muhammad Usman
Muhammad Usman el 20 de Mzo. de 2015
Comentada: Voss el 21 de Dic. de 2023
I have hundreds of MAT files and i want to concatenate all these files to a single file,each MAT file has dimension of 69x128,here is the technique that I follwed before for fewer files but this is not comfortable for me please provide some comformtable and simpler way to dothe same job
a1=load(sprintf('datafile_%02d',1));
a2=load(sprintf('datafile_%02d',2));
P1 = a.dataselection(:,5:132);
P2 = a2.dataselection(:,5:132);
PO = [P1;P2];
save('PO')
load('PO')

Respuesta aceptada

Voss
Voss el 20 de Dic. de 2023
Editada: Voss el 21 de Dic. de 2023
N = 200; % number of files (assumed to be named datafile_01.mat, _02.mat, ..., _10.mat, ..., _99.mat, _100.mat, ..., as you have specified with '%02d')
C = cell(1,N);
for ii = 1:N
A = load(sprintf('datafile_%02d.mat',ii));
C{ii} = A.dataselection(:,5:132);
end
PO = vertcat(C{:});
save('PO.mat','PO')
  4 comentarios
Stephen23
Stephen23 el 21 de Dic. de 2023
Accepted, as it seems to answer the question.
Voss
Voss el 21 de Dic. de 2023
I appreciate it!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by