-1

I would like to incorporate an xlsread instruction into a loop running over a list of different years. My intention is that at every loop the cell range changes, in order to import data for the respective year. I would like the cell range to move to the column to the right of the previous cell range. Is there any way to do this?

Thank you for your suggestions!

Adriana LE
  • 139
  • 2
  • 9
  • 1
    you can look at how to generate string from number to call the different ranges into your loop, but this will create a lot of overhead. The general advice would be to read all what you need in one shot, then deal with your _Matlab_ cell array in your loop. – Hoki Oct 13 '14 at 23:01
  • I tried creating string arrays indicating the cell range on each loop but it didn't work. I think your suggestion is way simpler, Thanks! – Adriana LE Oct 14 '14 at 18:09

1 Answers1

0

It's not possible for this to happen automatically.

Repeated calls to xlsread are very slow. because each one opens an instance of the Excel application. You're better off reading all of the data in one go, then stepping through the resulting array in MATLAB.

Nzbuu
  • 5,241
  • 1
  • 29
  • 51
  • Yes, you're right. I was not approaching the problem efficiently. I already did like @Hoki and you suggested and it's working perfectly. – Adriana LE Oct 16 '14 at 19:50