coding for divided Matrix