HughBorg

10 Reputation

One Badge

7 years, 284 days

MaplePrimes Activity


These are questions asked by HughBorg

My "for loop" index is being treated as a letter and not a number. The 'h' in my for loop is is supposed to be the index for these tables but the result is tables that have indices of the letter 'h'.  

The indexing for the 'Z' part works Z[h][1] ,Z[h][2] and Z[h][3] have numbers instead of the letter 'h' but the x1[h], y1[h] and Q[h][1],Q[h][2] and Q[h][3] are all 'h' indexed with no number as an index when I view this table in the variable viewer.

 

for h to 50 do :

Z[h][1] := s -> evalf(subs(x = x1[h](s), y = y1[h](s), Q[h][1])) ;

Z[h][2] := s -> evalf(subs(x = x1[h](s), y = y1[h](s), Q[h][2]));

Z[h][3] := s -> evalf(subs(x = x1[h](s), y = y1[h](s), Q[h][3])); 

end do:

the result is just using the last value of index 'h' and puting it in the first index of 'Q'. There is nothing defined with index 51.

Z[2][3](4*(1/50));
                            Q[51][3]
Z[9][3](4*(1/50));
                            Q[51][3]
 

if I hard code the index numbers then it works correctly but I do not want to hard code all 50 of these.  

Z[1][1] := s -> evalf(subs(x = x1[1](s), y = y1[1](s), Q[1][1]));
Z[1][1](4/50);
                   HFloat(-4.977040014616719)
Z[1][2] := s -> evalf(subs(x = x1[1](s), y = y1[1](s), Q[1][2]));
Z[1][2](3/50);
                  HFloat(-2.0000000000987943)
Z[1][3] := s -> evalf(subs(x = x1[1](s), y = y1[1](s), Q[1][3]));
Z[1][3](3/50);
                          1.563178208

 

Why is the for loop index variable 'h' treated as a letter and not evaluated to be a number in the indexing?

thanks . . . 

Page 1 of 1