average of one column of many text file

3 ビュー (過去 30 日間)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya 2016 年 5 月 20 日
コメント済み: Arashdeep Singh 2021 年 7 月 10 日
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 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 5 月 20 日
Your question is not clear

サインインしてコメントする。

採用された回答

KSSV
KSSV 2016 年 5 月 20 日
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 件のコメント
rebecca wise
rebecca wise 2020 年 2 月 3 日
can this code work for xlsx files?
Arashdeep Singh
Arashdeep Singh 2021 年 7 月 10 日
No, it cannot; it is specifically matlab code

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by