Error, final value in for loop must be numeric or character - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Error Message Guide : finalvalueinloopmustbenumeric

Error, final value in for loop must be numeric or character

 

Description

Examples

See Also

Description

The terminal condition in a for loop must be a numeric value, except when iterating over the letters in a string where a character is accepted.

Examples

Example 1

Note that n has no value.

 

for i from 1 to n do     sinπ2iend do;

Error, final value in for loop must be numeric or character

 

Solution:

Define n  to correct this error.

n4

n:=4

(2.1)

for i from 1 to n do     sinπ2iend do;

1

0

1

0

(2.2)

 

Example 2

In this example x is set to 13j where j has no value.

Gprocx      local i1;      to x do           iix      end do  end proc:

G13j

Error, (in G) final value in for loop must be numeric or character

 

Solution:

As with the previous example, define  j to correct this error.

j7

j:=7

(2.3)

G13j

46656

(2.4)

 

Example 3

Here N is not initialized to a numeric value.

 

for n to N1 do      xn+1  xn+Δxn; yn+1  yn+Δyn  end do;

Error, final value in for loop must be numeric or character

 

Solution:

Initialize N.

N5

N:=5

(2.5)

for n to N1 do      xn+1  xn+Δxn; yn+1  yn+Δyn  end do;

x2:=x1+Δx1

y2:=y1+Δy1

x3:=x1+Δx1+Δx2

y3:=y1+Δy1+Δy2

x4:=x1+Δx1+Δx2+Δx3

y4:=y1+Δy1+Δy2+Δy3

x5:=x1+Δx1+Δx2+Δx3+Δx4

y5:=y1+Δy1+Δy2+Δy3+Δy4

(2.6)

See Also

loops


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam