NOTE: This question is very similar to this one but I realized reading at the answers that I made a mistake in the equation AND I was not clear enough about what I need (my apologies):
I want to evaluate this expression:
expr1[i_,j_] = β[j]*ϕ[i, j]* C[i]
For $i=1:4, \, j=1:4$ with $i \ne j$, so over this list of tuples:
A = {{1, 2}, {1, 3}, {1, 4}, {2, 1}, {2, 3}, {2, 4}, {3, 1}, {3, 2}, {3, 4}, {4, 1}, {4, 2}, {4, 3}}.
so that I get:
expr1[1,2] = β[2]*ϕ[1,2]*C[1]
expr1[1,3] = β[3]*ϕ[1,3]*C[1]
...
expr1[4,3] = β[3]*ϕ[4,3]*C[4]
I have tried the following code:
expr2ind[i_, j_] :=
dInf2[i, j] = β[
j]*(ψ[i, j] Boole[i != j]*
R[i] + ϕ[i, j] Boole[i != j]* C[i]) - γ[j]*
Inf2[i, j] Boole[i != j]
Do[expr2ind[i, j][[1]];
CellPrint@Cell[BoxData@ToBoxes@expr2ind[i, j], "Input"], {i, 1,
4}, {j, 1, 4}]
This works well, except for the fact that the "Do" loop still computes the pairs (i,i), getting the following message: Part::partd: Part specification 0[1] is longer than depth of object. >>
and getting a
0
which I am trying to avoid. Basically, I want to know if there is a way to iterate over a particular set of tuples in Mathematica, equivalent to Python or Matlab. Thanks