Skip to main content
15-Moonstone
July 9, 2026
Question

Changing the iterator

  • July 9, 2026
  • 21 replies
  • 206 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 

21 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.

 

15-Moonstone
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.

15-Moonstone
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.

15-Moonstone
July 10, 2026

Hi Werner 

sigma’.v;ii;ontg .. this one has 1752 element and dzi_ontg has 1752 and the longest array in M is 1752 but still the function doesn’t work .. what should I do ?

R : has to calculate the sigma for the layer and the M and ( gama X dz) for the second layer 

 

Thanks I appreciate your help

Yusra

25-Diamond I
July 10, 2026

Have you made any changes to your sheet since the screenshot in the very first post here?
I'm confused and, in any case, I can't see why the error shown in the image in your first post should occur with sigma if both sigma and the largest vector in M have the same number of elements.
However, it is definitely a problem if `dz` and `gamma` don’t have at least one more element—see my comments here:

I can’t say for certain what you should change—that depends on exactly what you want to calculate when `MM`, `dz`, and `gamma` all have the same number of elements.
Obvious solutions would be to run the loop for i only up to last(MM)-2, or to add a sort of dummy element to the end or the beginning of the vectors dz and gamma.
However, I can’t say whether the results would still be exactly what you need.

15-Moonstone
July 13, 2026

Yes it becomes slower .. in Prime 10 the same calcs were faster. I will update the file and share with you. Thanks for the help