# Tag Info

9

Use Replace with a level specification instead: data1 = { {"A1","B1","C1","D1","E1"}, {"A2","B2","C2","D2","E2"}, {"A3","B3","C3","D3","E3"}, {"A4","B4","C4","...

6

You can use CoefficientArrays for this: outcomeMatrix = CoefficientArrays[eqnList, Array[outcome, 3]][]; coeffMatrix = CoefficientArrays[eqnList, Array[state, 3]][]; CoefficientArrays returns SparseArray objects by default. You can convert to normal matrices using Normal: Normal @ outcomeMatrix Normal @ coeffMatrix {{0, 0, 0}, {-0.51, 0, 0}, {-0.15, -...

5

Try Prepend Prepend[#, "T"] & /@ data1 {{"T", "A1", "B1", "C1", "D1", "E1"}, {"T", "A2", "B2", "C2", "D2", "E2"}, {"T", "A3", "B3", "C3", "D3", "E3"}, {"T",...

5

It is because _ operator starts at top where it found List and only if number of elements in list are same as _(as a requirement of _), it will recognize it otherwise it will go down to elements of each list. Say you do a small test, data2 /. {a_, b_, c_, d_, e_} /; ListQ[a] -> {"T", a, b, c, d, e} It returns, {{"A1", "B1", &...

2

Try the following. Let us introduce two rules: rule1 = {Dot[e1, a_]^2 :> x.a*y.a, Dot[a_, e1]^2 :> x.a*y.a}; rule2 = {Times[Dot[e1, a_], b___, Dot[c_, e1]] :> Times[Dot[x, a], b, Dot[c, y]] + Times[Dot[y, a], b, Dot[c, x]], Times[Dot[a_, e1], b___, Dot[c_, e1]] :> Times[Dot[a, x], b, Dot[c, y]] + Times[Dot[a, y], b, Dot[c, x]], Times[...

1

1. You can use a Do loop redefining the matrix C2 as Unitize[C2 + MatrixPower[C2, i]] at step i: SeedRandom C2a = Table[RandomChoice[{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 30], {j, 1, 30}]; Do[C2a = Unitize[C2a + MatrixPower[C2a, i]], {i, 2, 10}] Display usingArrayPlot with matrix entries rendered using Epilog: ArrayPlot[C2a, ColorRules -> {1 -> Red}, ...

Only top voted, non community-wiki answers of a minimum length are eligible