フィルターのクリア

Read different file in certain category

2 ビュー (過去 30 日間)
Jason
Jason 2016 年 3 月 3 日
コメント済み: Jason 2016 年 3 月 4 日
If I have some file folders, like '19800101', '1980012',... '19801201',... In each file, it have a .mat file. I want to deal with folder according to if their belong to same month. like, .mat file in folder '19800101' and '19800102' should be done with same action.
  2 件のコメント
per isakson
per isakson 2016 年 3 月 3 日
"In each file" &nbsp should that be "In each folder"?
Jason
Jason 2016 年 3 月 3 日
Yes. In each folder. Thanks for correction

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

採用された回答

Ahmet Cecen
Ahmet Cecen 2016 年 3 月 3 日
Grab a list of all the folders in a given month using something like:
files = dir('198001*');
Check MATLAB Regex for more elaborate sub-set extraction schemes you might need later here: http://www.mathworks.com/help/matlab/ref/regexp.html
You can then read all mat files in those folders with a for loop like:
for k = 1:length(files)
Data{k} = load([files(k).name,'\nameofmatfileinside.mat']);
end
This assumes the name of the matfile is the same inside all of those folders, which I suspect is the case. Also the direction of the directory slash might differ based on operating system.
  7 件のコメント
Ahmet Cecen
Ahmet Cecen 2016 年 3 月 3 日
Ooh, nice.
Jason
Jason 2016 年 3 月 4 日
Thanks for providing such efficient algorithm

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by