Matlab read and write file in loop

I have several csv files and want to read this file in a loop, the files are called a1.csv, a2.csv, a3.csv I can read those files like this
csvfiles = dir('*.csv')
for file = csvfiles'
fprintf(1,'Doing something with %s\n',file.name)
end
Within this loop I have to do some calculation with the data of each file. After this I want to store the output in several files according to the original name like a1_output.txt, a2_output.txt, a3_output.txt. Any help how I can do this?

 採用された回答

Thorsten
Thorsten 2015 年 11 月 10 日
編集済み: Thorsten 2015 年 11 月 10 日

0 投票

csvfiles = dir('*.csv')
filenames = {csvfiles.name}
for fn = filenames
fprintf(1,'Doing something with %s\n', char(fn))
[~, n] = fileparts(char(fn));
outfn = [n '_output.txt']
end

1 件のコメント

Carina
Carina 2015 年 11 月 10 日
Thanks a lot

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2015 年 11 月 10 日

コメント済み:

2015 年 11 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by