Corrected mat array index (im to i)