I’m not convinced either:

The problem is here:
ModY = @(y) [20*(y<20) + 80*(y>80) + y.*((y>=20)&(y<=80))]; ^ NEED ARRAY MULTIPLICATION HERE
You need to do array multiplication of ‘y’ and the logical array created by the ‘((y>=20)&(y<=80))’ inequality. (I recognised this because I’ve seen something like this code quite recently!)
With that, it works:
%20-%202015%2005%2003.png)
The reason it produced one value with the scalars and another with the matrices was due to the omitted element-wise array operator multiplication (.*).