cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

This array index is invalid for this array

SFares
13-Aquamarine

This array index is invalid for this array

Hello,

In the attached Mathcad sheet, when you scroll about one third down , under section 5.1, i get the error"This array index is invalid for this array". i am not sure what the error is and how to fix it. it happens in all the areas under section (5.1).Any assitance will be appreciated. Thanks!

7 REPLIES 7
Werner_E
25-Diamond I
(To:SFares)

Use "Trace error" to let you show the position of the error. Its in the sum above.

You are summing from 0 to n.P+1. n.P=20, so the max index is 21.

The sum uses vector P which has 22 elements and vector NC_a which has only 21 elements. So index 21 is invalid for vector NC_a.

Can't tell how to fix as I cannot be bothered wading through THAT file 😉

SFares
13-Aquamarine
(To:Werner_E)

you stated that vector P has 22 elements. how did you determine that?Thanks!

Fred_Kohlhepp
23-Emerald I
(To:SFares)

There are two useful commands:

rows(P) tells how many rows there are in a matrix or vector

cols(P) tells how many columns

rows(P) tells how many rows there are in a matrix or vector

cols(P) tells how many columns

Yes, useful, indeed. And for vectors we additionally have lenght(P) and last(P).

I used the latter - it returns the last valid index of a vector and in case of your P this is 21.

But of course rows(P) would have done the job as well.

SFares
13-Aquamarine
(To:Werner_E)

There issomething i dont understand., in your answer, you stated vector P has 22 elements, but when i count the elements there are 21.in your last answer, the index for P is 21. when i typed rows(P) i get 21.

Werner_E
25-Diamond I
(To:SFares)

No, I got 22 rows, indexed from 0 to 21 for P. This wasn't the problem. The problem was NC_a which had one element less.

err2.png

err1.png

Werner_E
25-Diamond I
(To:SFares)

Sorry, I have problems inserting pics when I edit a post the second time.

So lets try it again:

err1.png

err2.png

Announcements

Top Tags