Constraining the columns of a Matrix

In reply to dave_59:

Hello, that solution does not work in my case since I am using a packed array. Is there any other solution you can suggest?