Question: Invalid subscript in for statement

Hallo,

I am new with Maple and encountered the following problem.

The following code opens Excel Workbooks (Test1.xls, Test2.xls,...) and stores the values in the
variable data. data is then used to perform a simple operation (second and third for statement),
which calculates curvature.

When the first for statement runs from 4 to 5 (for r from 4 to 5 do) the loop works (accidently?) fine, but when I use
for r from 1 to 10 do the message "Error, invalid subscript selector" appears. The problem seems to
be in the matrix data. How can I avoid the error message?

Many thanks.

with(ExcelTools);
for r from 1 to 8 do

Name[r] := sprintf("C:/Test%d.xls", r);
q[r] := Import(Name[r]);
data := convert(q[r], listlist);
n := nops(data);
curvature := matrix(n, 11);

for i from 1 to n do
for j from 1 to 11 do
if j < 2 or j > 10 then
curvature[i, j] := 0:
else
curvature[i, j] := data[i, j+1]-data[i, j]:
end if
end do:
end do:

end do:

Please Wait...