フィルターのクリア

how to read all files that match certain names

2 ビュー (過去 30 日間)
ccs
ccs 2015 年 3 月 20 日
コメント済み: Adam 2015 年 3 月 20 日
I have files named using dates. I have a variable called 'allfiles' containing all files to access. Now I used another variable called 'datelist' containing dates list of variable 'allfiles' i.e. 2013-06-25, 2013-06-26,...
I have used this 'datelist' to separate weekdays and weekend days. Now I have trouble how to access the files of weekdays only or of weekend days only. I'm using R2014b
filenames are saved like this in the database (lots of them)
2013-06-25.mat
2013-06-26.mat
THANK YOU.

採用された回答

Adam
Adam 2015 年 3 月 20 日
Whatever logic you used on your datelist variable to separate out weekend days should come with a set of indices for these. Just keep hold of these indices and use them for logical indexing into your allfiles variable, assuming they are stored in the same order.
  2 件のコメント
ccs
ccs 2015 年 3 月 20 日
編集済み: ccs 2015 年 3 月 20 日
Thanks for the answer Adam. This is what I have used. Now those lists have dates only.I want to use that list (say weekend days list) to access files with those date names.
>>n=weekday(date_list);
>>weekEnds=find(n==1 | n==7);
>>myweekdays = date_list; % remove weekend days.
>>myweekdays(weekEnds) = []; % weekdays list
>>myweekEnds=datenum(date_list(weekEnds)); % weekEnds list
Path to Matfile: (not sorted into weekends and weekdays yet)
for i=1:numel(all_files)
year= datestr(date_list(i),'yyyy');
load([path '\' box '\' year '\' allfiles(i).name])
end
Adam
Adam 2015 年 3 月 20 日
weekendsIdx = find( n == 1 | n == 7 );
weekends = all_files( weekendsIdx );
should give you the list of weekend files.
Then load those as you seem to be doing. I haven't double-checked that your file loading code is correct, but unless that is what you are asking about I'll assume it is.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDialog Boxes についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by