load files automatically and combine

2 ビュー (過去 30 日間)
Lieke Numan
Lieke Numan 2019 年 4 月 5 日
コメント済み: Lieke Numan 2019 年 4 月 5 日
I have a lot of (about 100) short consequetive excel files with datestamps and data. I want to automatically load them in to matlab (all files in a specific folder), and them combine them into one file.
The name of the files is not changing with only a number, as it contains the timestamp of the first datapoint. So can I automatically load all files from a specific folder?
And how can I subsequently combine these files (or the date and data within this file) into one file?

採用された回答

KSSV
KSSV 2019 年 4 月 5 日
YOu should try some thing like below. It should work, if any error let me know.
files = dir('*xlsx') ;
N = length(files) ;
T = readtable(files(1).name)
for i = 2:N
T1 = readtable(files(i).name)
T = [T ; T1] ;
end
writetable(T,'test.xlsx')
  1 件のコメント
Lieke Numan
Lieke Numan 2019 年 4 月 5 日
Thanks a lot!
This worked:
b=[ ];
for i=1:length(myFiles)
name=[myFiles(i,1).name];
[~,a]=xlsread(name);
b=[b; a];
end
xlswrite(filename,b);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by