Keeping record of Number of concatenated files
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ARN
el 17 de Abr. de 2019
I am vertically concatinating some .mat files and i want to keep the track record of how many files i have concatinated;
Like putting 1 infront of values of file 1 (13780x1) and 2 infront of values of 2 (13840x1). Is there a way to do that?
Attached is the pic of random values; 3 files (15x1) concatinated so i want the left or the right answer.
![2019-04-17_14h42_57.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214491/2019-04-17_14h42_57.png)
4 comentarios
Respuesta aceptada
Stephen23
el 17 de Abr. de 2019
Editada: Stephen23
el 17 de Abr. de 2019
Inside your loop:
N = ... the total number of files.
C = cell(1,N)
for k = 1:N
M = ... import the matrix here.
M(:,end+1) = k;
C{k} = M;
end
Z = vertcat(C{:})
9 comentarios
Stephen23
el 2 de Mayo de 2019
Editada: Stephen23
el 2 de Mayo de 2019
" Any suggestions on that..."
Sure: using the code from my earlier comment, simply call fieldnames on T and then add a nested loop over those fields.
Then inside the nested loop add the extra column. After the nested loop allocate T to C.
Or, if you are feeling particularly adventurous, write something using structfun.
Más respuestas (0)
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!