load multiple .dat file and do the same calculation for same columns and make an output file
Mostrar comentarios más antiguos
Hello All and let me thank you for the time you spend to read my question I have seventy .dat file(s1.dat to s70.dat) each include 8columns and 6000rows, I want to find the maximum for column 5 and 6 for each .dat file and make a new file with 70rows and 2 columns(like following)
1 C5max C6max
2 C5max C6max
.
.
70 C5max C6max
I will appreciate every single tips or advice
3 comentarios
Walter Roberson
el 14 de Abr. de 2018
Samaneh Arzpeima
el 16 de Abr. de 2018
Walter Roberson
el 16 de Abr. de 2018
What error message did you see when you tried?
Respuestas (1)
Etsuo Maeda
el 17 de Abr. de 2018
If your sXX.dat is a csv file, the following code will help you to understand.
% generate 7 test files
for k = 1:7
T = randi(100, 6000, 8);
filename = ['csv', num2str(k), '.dat'];
csvwrite(filename, T);
end
clear; % clear variables
% load csvfiles, find maximum, store values
for k = 1:7
filename = ['csv', num2str(k), '.dat'];
S = csvread(filename);
M_col5 = max(S(:, 5));
M_col6 = max(S(:, 6));
M{k, :} = [M_col5, M_col6];
end
% save results
csvwrite('results.dat', M)
1 comentario
Samaneh Arzpeima
el 18 de Abr. de 2018
Editada: Walter Roberson
el 18 de Abr. de 2018
Categorías
Más información sobre Call C++ from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!