save column values of different multiple .txt files without overwriting in a for loop.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Angana Borah
el 18 de Sept. de 2019
Comentada: Angana Borah
el 19 de Sept. de 2019
yr = [1951:2018]';
for j = 1:size(A)
fil = importdata([folder, A(j).name]);
file = dlmread(fullfile(folder , A(j).name));
for i = 1:size(yr,1)
a = find(file(:,1)==yr(i));
M(i,1) = sum(file(a,4));
end
end
I imported all files using 'dir' ansd stored in A. The problem is that Only Last file is getting operated on.
2 comentarios
Respuesta aceptada
KALYAN ACHARJYA
el 18 de Sept. de 2019
I want to bring the 4th column of all the files in the sructure to one data_array,
- Read the txt file one by one (As you mentioned you have done it sucessfully)
- iter i=1
- Extract the 4th column from i file
- Save the column data in cell array
- Repeat, iter 2
Step 3:
col_data{i}=writetable(column_data,['file_test',num2str(i),'.txt'])
Más respuestas (0)
Ver también
Categorías
Más información sobre Low-Level File I/O 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!