Dear All,
Usually we define the array elements in the form x[0],x[1],x[2], etc
But instead can we define array elements in the form x[0.1],x[0.2],etc
In my code I use a For loop, within this loop I need to use array elements with decimal entries.
We all are aware of using integer elements in arrays like
For[j=1,j<6,j++,x[j]=2*x[j-1]];
my situation is i need to find x[0.1],x[0.2], etc. so i tried a code like the one below
For[j=1,j<6,j++,g=j/10; x[g]=2*x[g-0.1]];
Table[{j, x[j]}, {j, 0, 5, 0.1}]
and my output was
{{0., x[0.]}, {0.1, x[0.1]}, {0.2, x[0.2]}, {0.3, x[0.3]}, {0.4,
x[0.4]}, {0.5, x[0.5]}, {0.6, x[0.6]}, {0.7, x[0.7]}, {0.8,
x[0.8]}, {0.9, x[0.9]}, {1., x[1.]}, {1.1, x[1.1]}, {1.2,
x[1.2]}, {1.3, x[1.3]}, {1.4, x[1.4]}, {1.5, x[1.5]}, {1.6,
x[1.6]}, {1.7, x[1.7]}, {1.8, x[1.8]}, {1.9, x[1.9]}, {2.,
x[2.]}, {2.1, x[2.1]}, {2.2, x[2.2]}, {2.3, x[2.3]}, {2.4,
x[2.4]}, {2.5, x[2.5]}, {2.6, x[2.6]}, {2.7, x[2.7]}, {2.8,
x[2.8]}, {2.9, x[2.9]}, {3., x[3.]}, {3.1, x[3.1]}, {3.2,
x[3.2]}, {3.3, x[3.3]}, {3.4, x[3.4]}, {3.5, x[3.5]}, {3.6,
x[3.6]}, {3.7, x[3.7]}, {3.8, x[3.8]}, {3.9, x[3.9]}, {4.,
x[4.]}, {4.1, x[4.1]}, {4.2, x[4.2]}, {4.3, x[4.3]}, {4.4,
x[4.4]}, {4.5, x[4.5]}, {4.6, x[4.6]}, {4.7, x[4.7]}, {4.8,
x[4.8]}, {4.9, x[4.9]}, {5., x[5.]}}
Could anyone please help me to solve this issue?