updated for matlab matrix