I have a folder where the post processed files from a numerical model are stored with different names. for e.g. - WL.{simulation_name}.nc, UVel.{simulation_name}.nc, etc.
I am writing a generalized script in MATLAB to pick out the files that I need and process it further, irrespective of the simulation name :
dirFiles = dir(pwd)
for ii = 3:size(dirFiles,1)
s = dirFiles(ii).name
if strfind(s,'WL')
Data.WL = nc_varget(dirFiles(ii).name,'WL');
end
end
The problem is the folder usually contains more than 30-40 files with different variables. And the loops in the above script are immensely slowing down the processing time.
Is there any way to have a cleaner and faster solution?
P.S: One way would be to use eval function, But I really don't want to use it unless it is the last option.
Thanks!! Cheers.