average of one column of many text file
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tanmoyee Bhattacharya
el 20 de Mayo de 2016
Comentada: Arashdeep Singh
el 10 de Jul. de 2021
I have three hundrad text files and each have 4 columns.I have to do average of 3rd column of all the text files.It will come as a single column.How can we do this.
1 comentario
Respuesta aceptada
KSSV
el 20 de Mayo de 2016
txtfiles = dir '*.txt' ; % pick txt files in directory
Nfiles = length(txtfiles) ; % total number of files
iwant = zeros(Nfiles,1) ; % initialize the avg array
for i = 1:Nfiles % loop for each file
data = importdata(txtfiles(i).name) ; % load the data
iwant(i) = mean(data(:,3)) ; % get the mean
end
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings 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!