On 05/03/2012 01:32 PM, maxima at peutch.e4ward.com wrote:
> Dear all,
> Sorry for this very simple question, I basically would like to use
> arrays to create a bunch of repetitive variables.
>
> I would like to create variables for each of the 2x2 possible states of
> my model. Along the first dimension, the state is either a or b. Along
> the second: x or y.
>
> I started by creating manually:
> variable_ax: 1;
> variable_ay: 33;
> variable_bx: 4;
> variable_by: 50;
>
> What I would like to do is something like being able to assign:
> variable['a]['x] : 1;
> variable['a]['y] : 33;
>
> and so on. But i get an error (assignment: cannot assign to
> (variable['a])['x]).
> In other words, I would like to create arrays the indices of which are
> actually letters, not numbers.
>
> I looked and looked at the manual but arrays are a bit cryptic to me.
> Could anyone explain to me briefly how I could achieve that?
Why can't you use something like
(%i1) display2d : false;
(%o1) false
(%i2) a : makelist(concat(a_,k),k,1,7);
(%o2) [a_1,a_2,a_3,a_4,a_5,a_6,a_7]
Andre