Good evening! I hope this message finds everyone healthy and well.
I'm currently working with a series of .nc files which represent over five years of data. These files are all contained in the same folder and have a similar format (e.g MERRA2_100.inst6_3d_ana_Np.19800604.SUB.nc). I also have a matrix with three columns, where the first column indicates a month, the second column a day, and the third column a year (e.g. 06, 04, 1980).
My goal is to select all of the .nc files within my folder that match the dates included in my matrix. So, if the first row in my matrix indicates June 4th, 1980 (06, 04, 1980), I would like my code to select the appropriate .nc file from my folder (MERRA2_100.inst6_3d_ana_Np.19800604.SUB.nc). I would then like to read and average the variables in my selected files, but I think I know how I would like to go about with that. Any suggestions on this matter would be greatly appreciated. Thanks in advance!
Here's what I have so far:
matrix = [month day years]
myFolder = 'C:\Users\michelle\files'
filePattern = fullfile(myFolder, '*.nc')
theFiles = dir(filePattern)
for k = 1:length(theFiles)
baseFileName = theFiles(k).name
fullFileName = fullfile(theFiles(k).folder, baseFileName)
fprintf(1, 'Now reading %s\n', fullFileName)