util to read mat