필터 지우기
필터 지우기

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 CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by