bad index into Matrix - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Error Message Guide : bad index into Matrix

Error, bad index into Matrix

Error, bad index into Array

Error, bad index into Vector

 

Description

Examples

Description

Indexing into a Matrix, Array, or Vector must be done with integer values. Related to this, multi-element selection with a Matrix, Array, or Vector must also come down to integers at the endpoints. Trying to index a Matrix with a symbol will result in an error.

Examples

Example 1

Note that n has no value in this example.

 

A  1,2 ; 3, 4 

An,n

Error, bad index into Matrix

 

Solution:

In this case, defining n  corrects the error.

n1

n:=1

(2.1)

An,n

1

(2.2)

 

Example 2

This one is more subtle because the sum command is following Maple's normal evaluation rules. The index operation Vi is attempted before sum is called.  At this point, the name i does not have a value.

 

V  1,2, 3,4

sumVi,i=1..4

Error, bad index into Vector

 

Solution 1:

Evaluation of  Vi needs to be delayed using right single quotes.   

sum 'Vi', i=1..4 

10

(2.3)

 

Solution 2:

Instead of sum, use add.  The add command is recommended for adding a finite sequence of values.  The add command has special evaluation rules, so no error occurs in the evaluation.

add Vi, i=1..4 

10

(2.4)

 

 

Example 3
A nested call to sum with only one set of right single quotes leads to a different error. A second set of right single quotes corrects the problem.

 

A  Matrix3,i,ji+j

A234345456

(2.5)

sumsumAi,j,i=1..3,j=1..3;

Error, bad index into Matrix

sumsum'A'i,j,i=1..3,j=1..3;

Error, (in SumTools:-DefiniteSum:-ClosedForm) summand is singular in the interval of summation

 

Solution:

sumsum' 'A' 'i,j,i=1..3,j=1..3;

36

(2.6)

See Also

add

Matrices and Vectors

uneval