0
$\begingroup$

I have arrays defined as

xvar = Array[x, {n + 3, m + 3}, {{-2, n}, {-2, m}}]
yvar = Array[y, {n + 3, m + 3}, {{-2, n}, {-2, m}}]

whose values are determined by solving some system of equations. One of this equation should be condition on some elements of this array, whose one of the indices should bigger than zero e.g. I want all x[i,j], where j>0, but irrespective of value of i, to be zero.


Edit 1: Second part of the problem: I am having a problem with implementation of two simultaneous conditions. x_[i_, j_] /; i == 0 && j > 1 -> 0 does not work, nor x_[i_, j_] /; {i == 0 && j > 1} -> 0 , x_[i_, j_] /; {i == 0, j > 1} -> 0

Edit 2: x[i_, 0] /; i > 1 -> 0 - this works but the general question still stands for example i>0 and j>0

$\endgroup$
  • $\begingroup$ You might want to ask the "second part" as a new question instead, and add a link to this one. $\endgroup$ – J. M. is away Oct 27 '17 at 11:53
2
$\begingroup$
   xvar = Array[x, {n + 3, m + 3}, {{-2, n}, {-2, m}}] /. 
           x_[i_, j_] /; j > 0 -> 0
    yvar = Array[y, {n + 3, m + 3}, {{-2, n}, {-2, m}}] /. 
           x_[i_, j_] /; j > 0 -> 0

output: $$ \left( \begin{array}{ccccc} x(-2,-2) & x(-2,-1) & x(-2,0) & 0 & 0 \\ x(-1,-2) & x(-1,-1) & x(-1,0) & 0 & 0 \\ x(0,-2) & x(0,-1) & x(0,0) & 0 & 0 \\ x(1,-2) & x(1,-1) & x(1,0) & 0 & 0 \\ x(2,-2) & x(2,-1) & x(2,0) & 0 & 0 \\ x(3,-2) & x(3,-1) & x(3,0) & 0 & 0 \\ \end{array} \right) $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.