I'm trying to do the following. I have a table, call it TransTable
. To give an example
TransTable = {{0., 6.9, 7., 7.1, 13.9, 14., 14.1, 21.}, {0., 0., 0.100005, 0.20001,
7., 7.1, 7.20001, 14.1}, {0., 0., 0., 0.100005, 6.9, 7., 7.1,
14.}, {0., 0., 0., 0., 6.79999, 6.9, 7., 13.9}, {0., 0., 0., 0., 0.,
0.100005, 0.20001, 7.1}, {0., 0., 0., 0., 0., 0., 0.100005,
7.}, {0., 0., 0., 0., 0., 0., 0., 6.9}, {0., 0., 0., 0., 0., 0., 0.,
0.}}
What I want to do is as follows. This table has dimensions 8 by 8, or in general x
by y
. I want to extract all nonzero values, call them z_xy, and define variables according to
Varyx = z_xy
So for example Var21 = -6.9 should follow from this.
Now, I've had a look around and I think some of the ingredients are contained in the answer to Get positions of all non zero matrix elements however I don't really see how to adapt this into naming the variables. Clearly NonzeroPositions can be used to find the positions, but the naming step would then not be obvious to me.