how to load mutiple mat files which has names in 'YYYYMMDD.mat' format?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suresh R
am 29 Okt. 2021
Beantwortet: Bjorn Gustavsson
am 29 Okt. 2021
how to load mutiple mat files which has names in 'YYYYMMDD.mat' format?
0 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 29 Okt. 2021
You could do something like this, provided you have the filenames-of-interest:
for iFiles = numel(dataFiles):-1:1
Sloaded{i1} = load(dataFiles(iFiles).name);
end
If you have to get the filenames then look to dir and then select the files of interest there. If you need to load one data-file per day for every day from 1st of January 2017 to now you could do something like this:
D0 = datenum([2017 1 1]);
D = D0;
iD = 1;
while D < datenum(now)
filename = [datestr(D,'yyyymmdd'),'.mat'];
try
S{iD} = load(filename);
catch
disp(['failed to load file: ',filename])
end
iD = iD+1; % design-choice to make empty cell-arrays for missing data...
end
HTH
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!