- #1
rocks rock
- 3
- 0
Hi. I am trying to read csv files into Matlab. The files are x, y, z values for topographic profiles taken about 4 times a year over several years. I've worked out how to loop through each file and loop through names so that each comes in as a separate matrix. (see below) The problem I'm having is that some profiles are missing for certain years or seasons. So when Matlab comes to one of those files it says "Error File Not Found." I'm wondering if there is a way to skip over files that just don't exist.
Thanks
File naming scheme: prof_#_seasonyear
Ex: prof_3_sp08
Sample of code I'm using:
for i = 2:49
fname=sprintf('prof_%d_sp99.out',i);
eval(['sp99_prof_' num2str(i) '= csvread(fname);'])
fname=sprintf('prof_%d_sp00.out',i);
eval(['sp00_prof_' num2str(i) '= csvread(fname);'])
fname=sprintf('prof_%d_sp01.out',i);
eval(['sp01_prof_' num2str(i) '= csvread(fname);'])
end
Thanks
File naming scheme: prof_#_seasonyear
Ex: prof_3_sp08
Sample of code I'm using:
for i = 2:49
fname=sprintf('prof_%d_sp99.out',i);
eval(['sp99_prof_' num2str(i) '= csvread(fname);'])
fname=sprintf('prof_%d_sp00.out',i);
eval(['sp00_prof_' num2str(i) '= csvread(fname);'])
fname=sprintf('prof_%d_sp01.out',i);
eval(['sp01_prof_' num2str(i) '= csvread(fname);'])
end