- http://www.mathworks.com/matlabcentral/answers/57445-faq-how-can-i-create-variables-a1-a2-a10-in-a-loop
- http://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files
Looping through mat files or tables
19 ビュー (過去 30 日間)
古いコメントを表示
Could you please suggest a way to loop through a series of .mat files. The mat files contain a table, and have a name that describes the data. The tables have the same column names.
I want to go into each table and do a series of calculations on the data. (They are the same calculations and loops).
I was hoping I could load each mat file, assign a new table number for each, such as t1, t2, t3, t4...etc. so I could use this with a for loop. Something like this,
.
load D11srdbc.mat;
t1 = D11srdbc;
load C15srdbc.mat;
t2 = C15srdbc;
for i = 1:2;
newtable = sprintf('t%d(Var16)',i)
newtable(Var1)*....various calculations
end
.
The tables are around 200x30, with different types of data in the columns.
Many Thanks, Chris version r2015a
0 件のコメント
回答 (1 件)
Jan
2015 年 7 月 7 日
編集済み: Jan
2015 年 7 月 7 日
Do not hide indices in the names of variables as in "t1", "t2", ... . See:
DirList = dir(fullfile(Folder, '*.mat'));
Data = cell(1, length(DirList));
for k = 1:length(DirList)
Data{k} = load(fullfile(Folder, DirList(k).name));
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!