I am writing code which performs a matrix calculation, generates a matrix result A, and then I want to put the elements of A into variables (or scalars, or locals).
To illustrate, the matrix A = [2 5 6], and has column names A1 A2 A3. The issue is that I am unable to use column names to extract the desired elements, as the following illustrates:
. mat list A
A[1,3]
A1 A2 A3
r1 2 5 6
. di A[1,2]
5
. di A[1,A2]
A2 not found
r(111);
. di A[1,"A2"]
matrix operators that return matrices not allowed in this context
r(509);
What am I doing wrong?
To illustrate, the matrix A = [2 5 6], and has column names A1 A2 A3. The issue is that I am unable to use column names to extract the desired elements, as the following illustrates:
. mat list A
A[1,3]
A1 A2 A3
r1 2 5 6
. di A[1,2]
5
. di A[1,A2]
A2 not found
r(111);
. di A[1,"A2"]
matrix operators that return matrices not allowed in this context
r(509);
What am I doing wrong?
Comment