look at the value of number_panels on the very first time through the loops:
hourly_deficit(number_panels + 1, number_turbines + 1, h,d) =
hourly_deficit(1000 + 1), ...
and on last time through:
hourly_defisit(2000 + 1), ...
Similar things happen on the other indicies.
Maybe you want to have a iii = 0; outside the loop, and then
inside the outer loop and index with it?