how to read all files that match certain names

2 vues (au cours des 30 derniers jours)
ccs
ccs le 20 Mar 2015
Commenté : Adam le 20 Mar 2015
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.

Réponse acceptée

Adam
Adam le 20 Mar 2015
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 commentaires
ccs
ccs le 20 Mar 2015
Modifié(e) : ccs le 20 Mar 2015
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 le 20 Mar 2015
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by