Skip to main content
1 of 2
Tugrul Temel
  • 6.4k
  • 3
  • 14
  • 33

how to choose elements of a matrix with internally generated varaibles ($$var) and rank them with Real coefficients

I have a Code (a long one), part of it is below. The following piece basically multiplies an adjacency matrix with a vector of equilibrium values. Then tries to pick non-zero elements to be used in other sections of the Code. The entire Code is in DynamicModule with a Manipulate inside since I wanted to simulate the model with different random numbers.

My question is that, although I know "edgeWfinalsimul" exists with positive numbers, I cannot extract those numbers and hence the entire Code fails. The output from "edgeWfinalsimul" is { }.

Hope to receive some guidance. Thanks.

ClearAll[flowSSsimul, flowG0finalsimul, edgeWfinalsimul];
flowSSsimul = 
 Table[  Normal[G0][[i, j]]*tao[i]*alfa[j]*Subscript[x, i][t], {i, 1, 
   nn}, {j, 1, 
   nn}  ];  (* \[Equal][Subscript[g, \
(nn,nn)]\[SmallCircle]Subscript[[Subscript[\[Tau], i]Subscript[\
\[Alpha], j]], \
(nn,nn)]\[SmallCircle]Subscript[[Subscript[Overscript[x, ^], i]], \
(nn,nn)]] *)
flowG0finalsimul = 
 flowSSsimul /. 
  posSSsimul[[1]];  (* actual flow at the SS based on SS-info stocks \
"posSSsimul[[1]]" *)
edgeWfinalsimul = 
 Reap[Sow[#, # > 0] & /@ Flatten[flowG0finalsimul];, True][[2]] // 
  Flatten;(* extracts EdgeWeights of "flowG0finalsimul"*)

where "flowG0finalsimul" matrix is as follows:

{{0, 0, 0, 7.55596 FE`alfa$$1563[4] FE`tao$$1563[1], 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 7.55596 FE`alfa$$1563[19] FE`tao$$1563[1], 
  0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0.461227 FE`alfa$$1563[14] FE`tao$$1563[3], 0, 0, 0, 0, 0, 0}, {0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0.665655 FE`alfa$$1563[17] FE`tao$$1563[4], 0, 0, 0}, {0, 0, 0, 0, 
  0, 3.14909 FE`alfa$$1563[6] FE`tao$$1563[5], 0, 0, 0, 0, 
  3.14909 FE`alfa$$1563[11] FE`tao$$1563[5], 0, 0, 0, 0, 0, 0, 0, 0, 
  0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  3.34426 FE`alfa$$1563[11] FE`tao$$1563[6], 0, 0, 0, 0, 0, 0, 0, 0, 
  0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0}, {0, 0, 0, 1.66264 FE`alfa$$1563[4] FE`tao$$1563[8], 
  1.66264 FE`alfa$$1563[5] FE`tao$$1563[8], 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0}, {0, 0., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0., 0, 0, 0, 0.}, {0, 0, 0, 0, 0, 0, 0, 
  4.32564 FE`alfa$$1563[8] FE`tao$$1563[10], 0, 0, 0, 
  4.32564 FE`alfa$$1563[12] FE`tao$$1563[10], 0, 0, 0, 0, 
  4.32564 FE`alfa$$1563[17] FE`tao$$1563[10], 0, 0, 0}, {0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 
  1.02967 FE`alfa$$1563[14] FE`tao$$1563[11], 0, 0, 0, 0, 0, 0}, {0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 
  0, 0, 0, 154.893 FE`alfa$$1563[7] FE`tao$$1563[13], 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 
  0.152293 FE`alfa$$1563[6] FE`tao$$1563[14], 0, 0, 0, 0, 0, 0, 
  0.152293 FE`alfa$$1563[13] FE`tao$$1563[14], 0, 0, 0, 0, 
  0.152293 FE`alfa$$1563[18] FE`tao$$1563[14], 0, 0}, {0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0., 0, 0, 0, 0,
   0, 0., 0., 0, 0., 0., 0, 0, 0, 0., 0, 0, 
  0.}, {5.96944 FE`alfa$$1563[1] FE`tao$$1563[17], 0, 0, 0, 0, 0, 0, 
  0, 0, 5.96944 FE`alfa$$1563[10] FE`tao$$1563[17], 0, 0, 0, 0, 0, 0, 
  0, 5.96944 FE`alfa$$1563[18] FE`tao$$1563[17], 0, 0}, {0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 
  1.93381 FE`alfa$$1563[3] FE`tao$$1563[19], 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 1.93381 FE`alfa$$1563[13] FE`tao$$1563[19], 0, 0, 0, 0, 0, 0, 
  0}, {0, 0, 0., 0, 0, 0, 0., 0., 0., 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0}}
Tugrul Temel
  • 6.4k
  • 3
  • 14
  • 33