Update matrix with my function