Saad
Posts:
18
Registered:
11/26/12
|
|
break a loop when reading different excel files
Posted:
Nov 26, 2012 9:31 AM
|
|
Dear all,
I am trying to read different excel files from 2010 to 2012. Basically, for each month, there is one excel file. So when i run the loop I go through each month and read the excel file of that particular. The loop works with no problem for 2010 and 2011 but it stops at the end of 2012 because the data for November and December 2012 are not available yet. Here is my code:
months={'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'};
for i=2010:2012
for j=1:length(months) a1=xlsread(['P:\X\Data\', num2str(i),'\', char(months(j)), num2str(i), '.xls'],'Sheet1','X5:X5000');
end end
As you can see the loop reads the excel file at each month but stops at end 2012. I would like to end (break) the loop when Matlab doesnt find the relevant excel file. How can I do that? Thank you very much for your help
Kind REgards
S
|
|