I follow your code up to MultiValuedTest. In MultiValuedTest what is the purpose of diff (which is simply 0 there, so MultiValuedTest could just be defined to be state>0) and where is a dependency of MultiValuedTest on x on the right hand side?  Also--just a quick comment on coding--you should define MultiValuedTest in terms of a delayed evaluation (:=) instead of immediate evaluation(=). And Return is never necessary: Mathematica returns the final result of a sequence of expressions.
However, if your question is how to apply a function to the elements of a matrix you can use Map.
For example, here is a random 5x5 matrix:
mat = RandomReal[{0, 1}, {5, 5}]
And you can use Map to apply a function f to all its elements individually in this way:
Map[f, mat, {2}]
If this is not your question could you clean up your code so that it works and then rephrase?