I used a for loop to make 4 variables:
For[i = 0, i < 4, i++,bi=0]
But when I write b0
or b1
it print its as b0 or b1 not 0
or 0
.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityYou might find it easier to do
For[i = 0, i < 4, i++,b[i]=0]
b[3] (* gives 0 *)
You could use ToExpression
For[i = 0, i < 4, i++, ToExpression["b" <> ToString[i] <> "=" <> ToString[i]]]
and now
I am not sure why you want to do the above, there could be better ways to solve the problem you are trying to solve if you explain the purpose of doing this.
b[i_] = 0
to make every value zero (as a pattern), or you could restrict it to your values withb[i_Integer /; 0 <= i < 4] = 0
. Please read an introduction to the Wolfram language. $\endgroup$