Skip to main content
14-Alexandrite
July 9, 2026
Question

Changing the iterator

  • July 9, 2026
  • 4 replies
  • 17 views

Hi There ,

I have two functions are exactly the same but in two different sheet in the first sheet . it works perfectly and I’m getting the expected answers for f2

In the second sheet it doesn't work and I suspect the reason is M has different arrays . How can I fix this function : the error says : This array index is invalid. The index must be an integer, not less than ORIGIN, and not greater than the last element."

I can’t attached simplified sheet even in zip file. I hope you can help 

Thanks in advance , 

Yusra 

4 replies

25-Diamond I
July 9, 2026

According to the error position the problem seems to be with your sigma’.ontg variable which seems to have not as many elements as the corresponding vector in M.

 

i also notice that your function has four arguments but it uses only the first of them (M).

The other arguments dz, gamma’ and sigma’ are not used at all in the first picture. In the second gamma’ is used, but dz and sigma’ still not.

 

14-Alexandrite
July 9, 2026

The sigma and dz are just different in names and for M we did the same in both sheets 

 

Thanks 

Yusra 

25-Diamond I
July 9, 2026

It doesn’t make sense to define a function with arguments which are not used in the function in any way!

Check if the sigma’, gamma’ dz which you are using in the program have at least as many elements as the largest vector in M.

Otherwise thats the reason for the error und you have to decide what to do with a vector in M which has more elements than sigma’, etc.

14-Alexandrite
July 9, 2026

Yes you are right dz , sigma have [ 1752] rows , however M has [ 1478x1] [1752x1][1622x1][1718x1]  and I defined Mi to be [ 1478x1] like the first row 

25-Diamond I
July 9, 2026

Which sigma?? You are using so many different sigmas?

The sigma which has to have at least 1752 elements is sigma’.v;ii;ontg which is defined somewhere above the position picture is showing.

sigma’ which seems to be defined also somewhere in your sheet does not matter at all because, as already written, the function does not use the argument at all.