Error: ...initial value in for loop must be numeric or character
...increment of for loop must be numeric
...increment when looping over characters must be an integer
...final value in for loop must have same type as initial
Description
Examples
The error messages related to loops indicate that elements must be numeric, character, or integer.
Initial value
Error, initial value in for loop must be numeric or character
If the final value is numeric, ensure that the initial value is numeric, for example, 1.
If the final value is a character, ensure that initial value is also a character.
Final value
Error, final value in for loop must be numeric or character
Use the type command to verify whether the value is numeric or character.
Ensure that the final value is numeric or character.
Increment of for loop
Error, increment of for loop must be numeric
Use evalf to evaluate the square root of 2, therefore making the increment numeric.
Increment when looping over characters
Error, increment when looping over characters must be an integer
Error, final value in for loop must have same type as initial
See Also
evalf
for
numeric
Download Help Document