new function in toolsVecAndMat (smartAverage), improves averageProfile allowing non equispaced xedges