check_variables function

Checks validity of variables' matrix