maximum_array = max(x, y); % for a 31*31 matrix and finding max over all elements max = max(count1, [], 'all');