The problem is that you are not setting output values between sample times. (Note, the block is not discrete, you are artificially trying to make it discrete but it is not, and hence the solver will call your block at times other than when floor(u3/Ts) == 1). You need to set values for y1 and y2 every time the block is called, not just when floor(u3/Ts) >= 1.
But, isn't your code just a discrete state-space description? If so, why not use the discrete state-space block?