Defining contrasts in ANOVA to compare mean differences I would like to run an analysis of variance (parametric or not) with two factors; each factor having two levels. So if x, y is are the levels of the first factor and 1, 2 the levels of the second I would like to calculate whether the difference x1-x2 is significantly different to the difference y1-y2 (with $n_{x1} \neq n_{x2} \neq n_{y1} \neq n_{y2} $), using either SPSS or Matlab. In SPSS I need to specify the LMATRIX coefficients but I have no idea what the coefficients need to be in this case. I am not sure if it possible to do this in Matlab at all. Any ideas or suggestions will be really appreciated.
This is related to a question I asked a while ago: Comparison of differences between pairs of samples of unequal size
 A: I don't think you need to explicitly define a contrast for that. If I understood it correctly, testing for an interaction between both factors should address your problem.
A: This answer is just to expand on Gaël Laurans's answer, clarifying why the contrast requested by the OP is equivalent to the interaction. Note: below I am using $*$ to represent element-wise multiplication, and $\cdot$ to represent the dot product.
Suppose the group means are in $\mu = (\mu_{x1}, \mu_{x2}, \mu_{y1}, \mu_{y2})$.
Then the contrasts for the simple effects of $x$ vs. $y$ and $1$ vs. $2$ are $C_1 = (+1,+1,-1,-1)$ and $C_2 = (+1,-1,+1,-1)$, respectively. 
And the contrast for the interaction is $C_3 = C_1*C_2 = (+1,-1,-1,+1)$. Notice we get the interaction contrast by element-wise multiplication of the two simple effect contrasts.
So in terms of the group means, the interaction effect is $C_3\cdot\mu = \mu_{x1} - \mu_{x2} - \mu_{y1} + \mu_{y2}$.
Okay. So now you want to test whether $\mu_{x1} - \mu_{x2} = \mu_{y1} - \mu_{y2}$. In other words, does the $\mu_{x1} - \mu_{x2}$ difference differ from the $\mu_{y1} - \mu_{y2}$ difference?
But notice that if we simply move all the terms over to the left-hand side we get $\mu_{x1} - \mu_{x2} - \mu_{y1} + \mu_{y2} = 0$. Look familiar? As we just saw above, this is equal to $C_3\cdot\mu$ = 0.
So the "difference in differences" that you want to compute is formally equivalent to the interaction effect. And you would test this difference using the $C_3$ interaction contrast given above.
