mats_explore modified to incorporate also 3D cases.